[ANN] Null Pattern implementation

Keith Hodges keith_hodges at yahoo.co.uk
Tue Oct 17 08:45:26 UTC 2006

I have resurrected Nevin Pratts Null Pattern implementation.


See examples below.

I also managed to get ifTrue:ifFalse: to work with the null pattern in 

best regards



Code like this:

  | tmp |
   tmp := person office.
   tmp notNil ifTrue: [tmp := tmp phone].
   tmp notNil ifTrue: [tmp := tmp lastNumberDialed].
   tmp notNil ifTrue: [lastNumber := tmp asString].
   widget setStringValue: lastNumber.

becomes code like this:

lastNumber := person office phone lastNumberDialed asString.
widget setStringValue: lastNumber.

Code like this:


   | ctrl |
   ctrl := self getController.
   ctrl isNil ifTrue: [^nil].
   " Trap errors occurring while searching for
   the object wanting control. "
   ^Object errorSignal
   handle: [:ex |
   Controller badControllerSignal
   'Bad controller in objectWantingControl']
   do: [ctrl isControlWanted ifTrue: [self] ifFalse: [nil]]

becomes Code like this:

   self getController isControlWanted ifTrue: [^self].
Send instant messages to your online friends http://uk.messenger.yahoo.com 

More information about the Squeak-dev mailing list