Smalltalk is a tidier functional language than Scheme
Patrick Logan
patrickl at servio.gemstone.com
Wed Sep 2 04:26:00 UTC 1998
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...
(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 ...)))
Not as tidy as Smalltalk! Smalltalk is a nice *semi-functional*
programming language! Objects and functions are *very* similar!
--
Patrick Logan mailto:patrickl at gemstone.com
Voice 503-533-3365 Fax 503-629-8556
Gemstone Systems, Inc http://www.gemstone.com
More information about the Squeak-dev
mailing list
|