[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LFM + LFSP = LFE?
On Sat, 14 Jun 2003, Michael Vanier wrote:
> This syntax looks decent. One question: is it "just syntax" or can one
> regard the block containing the method bodies as a message being sent to a
> class? Given my knowledge of ST syntax, I'd say it's the latter (no method
> selector), and that will annoy the purists. But then, I'm not a purist ;-)
Yup, it's "just syntax", and yes, that offends my sense of purity.
Realistically, though, there are only two ways I can think of that you
could make it a message send:
- use String literals for the method source. Maybe you could use curly
braces as a "smart" literal syntax that didn't need much escaping, so you
would get
Script compile: {
run
self puts: 'hello world'
}
for every method. This isn't very interesting, though.
- use a block to define each method. In the simplest case this would
probably look something like:
Script addMethod: #run do:
[:self |
self puts: 'hello world']
or
Script addMethod: #add:to: do:
[:self :x :y |
x + y]
To properly match the return semantics, you would have to pass a
continuation in as well:
Script addMethod: #add:to: do:
[:self :return :x :y |
return value: x + y]
I guess you could use the {} literal syntax to make this a little
friendlier, by defining #methods: to take associations from selectors to
blocks:
Script methods:
{#run ->
[:self :return | self puts: 'hello world'].
#add:to: ->
[:self :return :x :y | return value: x + y]}
If you got really clever you could make "self" and "return" be dynamically
scoped globals, so now we'd have something like
Script methods:
{#run -> [Self puts: 'hello world'].
#add:to: -> [:x :y | Return value: x + y]}
Comments?
Avi