Dijkstra-esque Guarded Commands in Squeak

Andrew C. Greenberg werdna at gate.net
Mon Aug 23 01:06:50 UTC 1999


>Maybe this has some pedagogical value.  It may also be a reasonably 
>nice way to construct an if-then-else structure in squeak.

A kind squeaker observed in private correspondence that Squeak, of 
course, has an if-then-else structure, to wit:

	booleanExpression
		ifTrue: [theThenThing]
		ifFalse: [theElseThing]

I meant, really the if-then-elif-else-style structures of some other 
imperative languages, for which squeak has no express elegant 
counterpart (and of which folks have reasonably and firmly argued are 
unnecessary as indicative of poor design or factoring).  Thus:

	{[theIfExpr] 	-> [theThenThing]
	.[theElif1Expr]	-> [theElIf1Thing]
	.[theElif2Expr]	-> [theElIf2Thing]
	.[theElif3Expr]	-> [theElIf3Thing]
.. . .
	.[theElifnExpr]	-> [theElIfnThing]
	.[true]		-> [theElseThing]
	} if





More information about the Squeak-dev mailing list