Context of Execution

Jack Waugh 95h62gq02 at sneakemail.com
Mon Jul 24 16:58:30 PDT 2006


> Huh? What do you mean by a "context"?

I thought you were using the term for an object that is understood to be used as
the implicit first argument of messages that didn't have an explicit one.  For
example,

foo. bar. bletch

is equivalent to

here foo.  here bar.  here bletch

right?  So what is "here" required by the language definition to be or do?

> A stack frame, perhaps?

I don't know whether the implicit argument is a stack frame or not.  Maybe so,
since it supports "^", and an early return sounds like a stack-framey thing to
be able to do.

> The  
> compiler determines whether it can execute a lexical (literal) block  
> in a method as a piece of bytecode or whether a separate Method  
> object must be created and then run in a separate stack frame.

I'm not asking what a compiler does, but rather what it is required to do in
order to comply with the language definition.

> src/ 
> mobius/vm/interp/compiler.slate has the details. Since Slate is  
> lexically-scoped, then of course it's implicit that contexts inherit  
> from the lexically-enclosing scopes.

Ah, so.  But the ">>" macro defeats that, doesn't it?

> > Where is the source code to the macro, "`>>"?
> 
> src/lib/macro.slate which has the documentation for it. (Grepping  
> "@.*>>" will find it for you).

No match.

jack at ubuntu:/usr/share/slate/src/lib$ egrep '@.*>>' macro.slate
jack at ubuntu:/usr/share/slate/src/lib$

> >   Doesnt' "`>>" pass an arbitrary
> > object (its left argument) as the context?
> 
> It takes an expression which `>> when expanded is evaluated and  
> possibly stored for a bunch of following statements to act on in the  
> left-most argument position.

And they act on it by using it as the implicit first argument.  So, for example,
in the definition,

par@(CC Parser traits) newOn: stream
[
  par clone `>>
   [scanner: (p scanner newOn: stream).
    nodeStack: Stack new. ]
].

the implicit first argument to the "scanner:" and "nodeStack:" and "p" calls is
the object returned by the evaluation of the expression "par clone", right?

In the story that you would tell about the meaning of this method in terms of
the language definition (rather than of whatever compiler might exist), how do
you explain the evaluation of the expression "Stack"?  It's a message expression
whose first argument is implicit.  Does that mean its first argument is the
object having been returned by "par clone" as well?  Do we expect that this
object inherits from the lobby or from CC (compiler compiler) and thereby can
field a "Stack" message?  The capital letter on "Stack" and its usage "new"
suggests that it's a prototype defined "globally".

> >   Does it cut off
> > access to the lobby, for example, for the code in the block that is  
> > the right
> > argument of "`>>", and for code called by that code?
> 
> No, the lobby or other scope can be accessed if using parentheses to  
> change the precedence ordering of evaluation.

Would you give an example of the use of parentheses to access the lobby from
inside the block that is the right argument of the ">>" macro?

In a compliant implementation,

2 `>> [+ 2]

should yield 4, right?  What about

2 '>> [+ lobby slotNames size]

Thanks.




More information about the Slate mailing list