Eiffel "Gotchas"

07 April 1998


Oops!

Gotcha #5 - null pointers

Suppose you wish to test that a pointer is not null before passing it to an external routine. On some Eiffel compilers, the following code will compile and run, but it won't work as expected. What's wrong?

   p: POINTER
   ...
   if p = void then
      print("Nil pointer.%N")
   else
      some_external_routine(p)
   end

ANSWER


Eiffel and NICE are registered trademarks of the Nonprofit International Consortium for Eiffel.

Eiffel "Gotchas"