Message Eating Null - article

Keith Hodges keith_hodges at yahoo.co.uk
Fri Jul 27 01:27:29 UTC 2007


Vassili Bykov wrote:
> On 7/26/07, Keith Hodges <keith_hodges at yahoo.co.uk> wrote:
>> As for flakiness, a generic message eating null, that does its job could
>> be less flaky than maintianing specific null-objects for different
>> domain models.
>
> The problem with message-eating null is that it will happily do *more*
> than its job. This is what I find objectionable. If you are somewhat
> familiar with Haskell, a message-eating null is very much like the
> Maybe monad. But unlike Haskell, without a type system to contain it
> all object references throughout the system effectively become
> maybe-values, and all implicit continuation calls turn into bind
> operators.
>
> In other words this means that a null accidentally leaking outside the
> area where it was expected can silently cause some actions to not
> happen. What you deal with in that case is not just a null of an
> unknown origin that Nevin focused on in his write-up, but things
> breaking because some code didn't run in the past because of a stray
> null value. When we write ifTrue:ifFalse:, we expect that each time it
> runs one of the branches is taken. In a system with message-eating
> null, this is no longer an invariant.
>
I see your point, however, I dont see that as much different to nil. 
Have you ever found something not working because a value you expected 
to be initialize was not, some time in the past.

I am not suggesting indiscriminate use of null. It is useful in some 
situations.

In actual fact in versions prior to my latest package releases null 
would not have been able to ignore ifTrue ifFalse anyway, it would have 
to throw an error. Neither can it in other languages such as ruby since 
ifTrue ifFalse are somewhat more wired in to the underlying runtime than 
in smalltalk.

best regards

Keith







Further more do you have any idea where in the past the initialization 
failed to happen.

With null you can find out where it started.



More information about the Squeak-dev mailing list