[squeak-dev] ifTrue: vs. ifFalse:

Erlis Vidal erlis at erlisvidal.com
Tue Oct 18 13:38:42 UTC 2011


In general negation can be confusing, but negations are not only
syntactically. You can find negation in the semantic also, e.g.: variable

You can find yourself with a variable name which express a negation, e.g.: *
abandoned* (I must admit this is not the majority of the cases)

In such situations, it's really convenient to have different combinations
that allow you to write the code that reads better. Which read better
between these?

abandoned not ifTrue: []
abandoned ifFalse: []

Maybe what you will discover is that most of the time you use ifTrue...
maybe you negate the variable or not... I think is not what you like the
most, but what you write most of the time that tent to be readable.


On Tue, Oct 18, 2011 at 9:20 AM, Louis LaBrunda
<Lou at keystone-software.com>wrote:

> Hi Guys,
> >On 18.10.2011, at 05:11, Chris Muller wrote:
> >
> >> (From vm-dev list)
> >>> But I much prefer foo ~~ bar ifTrue: than foo == bar ifFalse:.
> >>
> >> Hi Eliot.  May I ask why you prefer the former over the latter?
> >>
> >> I'm interested because I'm working on an application where the folks
> >> involved prefer something similar, to where they write (expr) not
> >> ifTrue: [ ] rather than (expr) ifFalse: [ ].
> >>
> >> I know you wouldn't do that but your statement definitely piqued my
> >> surprise and curiosity.
> >
> >Maybe this is a clue: very few other programming languages have an
> "else"-case without a preceding "if true". So maybe for people versed in
> multiple languages the ifFalse: feels wrong?
> >
> >I personally like "expr ifFalse:" better than "expr not ifTrue:". And I
> read "~~" as "not identical" which also has a mental "not" in it, so I
> prefer "== ifFalse" :)
> >- Bert -
> Allow me to throw out an outside the box (programming box) thought.  If one
> is able to mentally read "x ~= y ifTrue:..." or "x == y ifFalse:..." all in
> one look, I don't think it matters much as they know what the sentence says
> instantly.  It then becomes a matter of what they are use to.
> For those of us who read those sentences in two parts: "x ~= y" and
> "ifTrue:...", the "not" being included in the comparison is preferred as it
> tells us up front what the comparison is about.  Then the second part tells
> us what is being done about it.  I hope helps and makes some sense.
> Lou
> -----------------------------------------------------------
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
> mailto:Lou at Keystone-Software.com http://www.Keystone-Software.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20111018/c4d7a586/attachment.htm

More information about the Squeak-dev mailing list