Literal object syntax

Tony Garnock-Jones tonyg at lshift.net
Wed Jul 19 08:36:59 UTC 2006


Andreas Raab wrote:
> For sending message we introduce an "outer" keyword just like we have
> "super" today. So you may have something like here:
> 
> [...]
>
>> It also introduces the thorny notion of naming partial continuations.
>> (As in, which continuation does ^ throw to?)
> 
> Same as today. The difference between block and method is arbitrary
> (always has been) and I'd go so far as to say: "a method is a block you
> can return to", e.g., make the "returnability" part of what defines a
> method.

Well, both these solutions are practical and implementable; I still have
some questions though: Firstly, wrt "outer" - what about

someMethod
  ^ def Object [
      otherMethod [
        ^ def Object [
            furtherMethod [
              ^ outer service + 4
            ]]]
      service [
        ^ 4
      ]]

"outer" is ambiguous here. IMO, plain old lexical scoping (note: not
references to ivars, just to temps and arguments) is good enough - since
self is already available in each context to get what you want.

someMethod
  | serviceProvider |
  serviceProvider := def Object [... ^ serviceProvider service + 4 ...]



Actually, that's sort-of interesting: do the lexically-scoped variables
(temps, arguments) become the instance-variables of the anonymous class?


Secondly, regarding the distinction between blocks and methods: if "a
method is a block you can return to" (do you mean from?) then blocks and
methods are semantically different, and the syntactic equivalence I
sketched in my last message doesn't hold. Could we instead use
thisContext for finer control, and make ^ some kind of sugar for such use?

someMethod
  | leave |
  leave := thisContext.
  someCondition ifFalse: [ leave returnValue: nil ].
  ^ self complexComputation.

(I guess uses of ^ would have to cause a binding at the outermost
lexical level with the value of thisContext that occurs there.)

Then ^ works as it usually does, throwing control back to the enclosing
context of all the currently-visible text - as far out as you can see -
and we get finer control for the complicated cases it's needed.


Cheers,
  Tony




More information about the Squeak-dev mailing list