[squeak-dev] Re: [Pharo-project] Protocol extension proposal:
leves at elte.hu
Sat Dec 5 13:57:00 UTC 2009
On Sat, 5 Dec 2009, Igor Stasenko wrote:
> I currently writing a code which looks like:
> a := some numeric expression + (someBoolean ifTrue:  ifFalse: ).
> And i get somewhat tired repeating the same pattern in multiple places.
> So, i thinking , maybe #asBit convenience method could be useful?
It's useful IMO, so I use it whenever I need it. It's in the image
with 7/1/2004 timestamp.
> ^ 1
> ^ 0
> so, then, in case of need like above, we could write much shorter expressions:
> a := some numeric expression + someBoolean asBit.
> And its much less error prone comparing to #ifTrue:ifFalse:, since i
> found its relatively easy to make a mess (swapping 1 with 0),
> especially, when you having negations in expression, because once you see:
> (someBoolean not ifTrue:  ifFalse: )
> you always tempted to write it as:
> (someBoolean ifTrue:  ifFalse: ).
> or as:
> (someBoolean ifFalse:  ifTrue: ).
> but once you start playing with it, its very easy to shoot into own
> feet if you are not careful.
> But if we could add #asBit, then we could write:
> someBoolean not asBit
> which is much more:
> a) concise & cleaner
> b) error proof
> Best regards,
> Igor Stasenko AKA sig.
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
More information about the Squeak-dev