[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LFM + LFSP = LFE?




On Mon, 16 Jun 2003, Michael Vanier wrote:

> But does anyone actually do this?  All I've ever seen is the equivalent of:
>
> /bar/ ifTrue: foo.

Well, I've never seen anyone actually define BlockClosure>>if: so that you
could do

[action] if: condition.

However, there are some variations that do get used - for example,

[condition] whileTrue: [action]

vs.

[action. condition] whileTrue.

The more useful variations on if statements, IMO, are things like

foo ifNil: [...] ifNotNil: [...]

foo bar baz ifNotNilDo: [:result | ...]

someCollection ifEmpty: [...] ifNotEmpty: [:coll | ...]

> It's pretty trivial to implement ST-style OO in lisp; how easy is it to
> implement lisp in ST?

*Is* it that trivial?  From a syntax point of view (and that's what we're
talking about, right?), the most crucial things about smalltalk IMO are:

- super lightweight lambdas (the minimal thunk, [], is two characters)
- keyword selectors (*not* keyword arguments)
- message dispatch as the basic operation (no need to use a send
function or some such)

I've thought a little about how you would achieve those in Lisp, and to be
honest I never came up with anything that satisfied me, except by
transforming an entire method at a time (which is interesting but misses
the point).  There are some tradeoffs here between Scheme (which, being a
Lisp-1, can generally get away without a send function), and CL (which has
read macros and so can easily implement block syntax), but I haven't seen
a good way of getting all three of the above requirements at the same
time.

I'd be curious to hear if you have any better ideas for this than I did.
I'd also be curious to know what you consider the equivalent crucial
things about Lisp, to define what "implement Lisp in ST" might mean;
certainly there are compilers that let you write individual classes in
Lisp within a Smalltalk environment, but again that misses the point.

Avi