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

Re: LFM + LFSP = LFE?



On Sat, 14 Jun 2003, Avi Bryant wrote:

> On Sat, 14 Jun 2003, Michael Vanier wrote:
> - 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]

In Slate, we allow the user to omit the input block arguments from the
header and instead use them in the signature, and this is rewritten by the
parser into a canonical syntax model.

> 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]

Now this is interesting syntactically, because we had been using ^ as a
selector on method objects which leads to precedence confusion among
migrating Smalltalkers. We still use the continuation model of course.

> 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]}

This is even more interesting, and in Slate I could see an additional
benefit by combining this with accessing the method's slots for outer
calling contexts, so that a specific continuation could be chosen. Of
course, if you assume that dynamic scoping is available, you can also
introduce other continuations that way.

-- 
Brian T. Rice
LOGOS Research and Development
http://tunes.org/~water/