Smalltalk for Lispers
eq and equal
Translate directly to == and =
Atoms
Like lisp, smalltalk provides atomic character strings,
called symbols. In smalltalk, these behave much like strings,
with the exception of being readOnly (i.e. their character elements
cannot be changed) and being unique (i.e. they can be compared using
==).
Lambda
A smalltalk block is what you know as a lambda;
invokation is done by sending the block a #value: message.
for example, the following lisp code:
(define make-adder
(lambda (a)
(lambda (b)
(+ a b))))
(define add-two (make-adder 2))
(add-two 1)
-> 3
makeAdder is a lambda which evaluates to a lambda.
Lambdas are closures; i.e. they remember their defining environment.
translates directly into Smalltalk
(the hyphen is not valid in identifiers; we could use underscore instead):
makeAdder := [:a | [:b | a + b] ].
addTwo := makeAdder value:2.
addTwo value:1
-> 3
makeAdder is a block which evaluates a block.
Blocks are closures; i.e. they remember their defining environment.