[NIT] Pretty pretting #ifFalse:ifTrue:

Stephan Rudlof sr at evolgo.de
Mon Nov 19 19:33:37 UTC 2001


My finger has been too fast:

I wrote:
> 
> Bijan Parsia wrote:
> >
> 
> <snipped>
> 
> > Take this example:
> >
> >   testPPIf
> >         true ifTrue:[5]
> >              ifFalse:[nil] "Nothing now, but I may want to add
> >                                 something later."
> >
> > Ok, hardly wonderful style, but not *insane* either :)
> >
> > Pretty printed:
> >
> >    testPPIf
> >         true
> >                 ifTrue: [5]
> >
> > Uhm....
> >
> > Now *that's* crazy!
> >
> > Granted, it's semantically equivalent, but so?
> >
> >   testPPIf: aBool
> >         ^aBool ifTrue:[5]
> >                 ifFalse:[nil]
> >
> > seems semantically equivalent to:
> >
> >   testPPIf: aBool
> >         ^ aBool
> >                 ifTrue: [5]
> >
> 
> > But so is:
> >
> >   testPPIf: aBool
> >         aBool ifTrue:[^5]
> >                 ifFalse:[^nil]
> >
> > (ok, perhaps only in this simple example).
> >
> > And in that case PPing gets:
> >
> >   testPPIf: aBool
> >         aBool
> >                 ifTrue: [^ 5]
> >                 ifFalse: [^ nil]
> 

> Fully correct!
> 
> *Wrong* would be
>     testPPIf: aBool
>           aBool
>                   ifTrue: [^ 5]
> , since this would return self.

instead of nil in the false case.

> 
> Greetings,
> 
> Stephan
> 
> >
> > <sigh/> It adds a bit of magic to the system that's kind of worrisome
> > (espeically the killing of comments).
> >
> > Cheers,
> > Bijan Parsia.
> 
> --
> Stephan Rudlof (sr at evolgo.de)
>    "Genius doesn't work on an assembly line basis.
>     You can't simply say, 'Today I will be brilliant.'"
>     -- Kirk, "The Ultimate Computer", stardate 4731.3

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3




More information about the Squeak-dev mailing list