[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.
http://www.squeaksource.com/Null
See examples below.
I also managed to get ifTrue:ifFalse: to work with the null pattern in
squeak.
best regards
Keith
----------
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:
objectWantingControl
| ctrl |
ctrl := self getController.
ctrl isNil ifTrue: [^nil].
" Trap errors occurring while searching for
the object wanting control. "
^Object errorSignal
handle: [:ex |
Controller badControllerSignal
raiseErrorString:
'Bad controller in objectWantingControl']
do: [ctrl isControlWanted ifTrue: [self] ifFalse: [nil]]
becomes Code like this:
objectWantingControl
self getController isControlWanted ifTrue: [^self].
^nil
Send instant messages to your online friends http://uk.messenger.yahoo.com
More information about the Squeak-dev
mailing list
|