[NIT] Pretty pretting #ifFalse:ifTrue:

Bijan Parsia bparsia at email.unc.edu
Mon Nov 19 18:37:49 UTC 2001


On Mon, 19 Nov 2001, Bob Arning wrote:

> Tim,
> 
> I tried this and it seems to work either way.
> 
> before pretty printing --
> 	b _ (el bar) isNil ifTrue:[nil] ifFalse:[el bar].
> 
> and after pretty printing --
> 	b _ (el bar) isNil ifFalse:[el bar].
[snip]

Erk! Sorry, I just can't get past the fact that we're prettying the
*transformed* trees.

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]

<sigh/> It adds a bit of magic to the system that's kind of worrisome
(espeically the killing of comments).

Cheers,
Bijan Parsia.





More information about the Squeak-dev mailing list