Smalltalk is a tidier functional language than Scheme
Mike Klein
mike at twinsun.com
Wed Sep 2 04:38:58 UTC 1998
On Tue, 1 Sep 1998, Patrick Logan wrote:
> In my mind, this is one of the niceties of Smalltalk over Scheme...
> there are no special forms. If the parameter is a block, it
> evaluates to a BlockContext (or closure... hopefully, someday)
>
> Well, Scheme doesn't require special forms. It's just that a closure
> in Scheme is less tidy than in Smalltalk!
>
> | z |
> z := 0.
> [ :x :y | z := x + y + z]
>
> vs.
>
> (let ((z 0))
> (lambda (x y) (set! z (+ x y z)) z))
>
> Scheme has that wordy "lambda" keyword. Here's how a boolean based on
> closures would look in Scheme...
Of course, a reasonable implementation would actually use the greek lambda
symbol ;-) (and the emoticons would have Unicode characters as well)
> (define true (lambda (trueBlock falseBlock)
> (trueBlock)))
>
> (define false (lambda (trueBlock falseBlock)
> (falseBlock)))
>
> (set! boolean (compute-true-or-false ...))
> (boolean (lambda () (do-this-if-true ...))
> (lambda () (do-this-if-false ...)))
Yeah, I call these Church Booleans.
> Not as tidy as Smalltalk! Smalltalk is a nice *semi-functional*
> programming language! Objects and functions are *very* similar!
I agree, but look what a nice job they did on the numerics, not to
mention one of the best written language specs *ever*.
I wish we lived in a world where comparing Smalltalk and Scheme was a
major issue. Unfortunately, on any spectrum that includes C++/java,
Scheme and Smalltalk are unresolvable close together.
Whistfully,
Mike Klein
More information about the Squeak-dev
mailing list
|