Message-eating null?
Cees de Groot
cg at cdegroot.com
Thu Feb 24 22:55:26 UTC 2005
Hi,
http://www.smalltalkchronicles.net/edition2-1/null_object_pattern.htm
I got fed up with all the ifNil:.... tests in my domain code today, so
based on my excellent experiences with using the 'message eating null'
pattern in previous projects (with VW), I decided to add this thing to my
toolkit.
However, to my disappointment I found that #ifNil: and friends are
optimized by the compiler, so there's no way to override them (they're
compiled to '== nil' and a jump).
Is there a way to circumvent this? It really is a very useful thing to
have, it cleans up code in your domain layer tremendously.
(the only solution I could think of is changing the compiler and
recompiling the system. hardly attractive...)
More information about the Squeak-dev
mailing list
|