edu.vub.at.objects
Interface Method


 Method

ATMethods are the AmbientTalk's representation of methods as named functions. These functions do not close over an environment allowing for them to be shared between different clones. The environment is to be supplied during lookup (which wraps a method into a Closure). As a consequence, it is not possible to get hold of a method at the base-level (since lookup implies wrapping).

Author:
smostinc, tvcutsem

Method Summary
 Table annotations()
          Returns the annotations associated with the method.
 Object apply(Table arguments, Context ctx)
          Applies the method to the given arguments in the given context.
 Object applyInScope(Table arguments, Context ctx)
          Applies the method to the given arguments in the given context.
 Begin bodyExpression()
          Returns the body of the method.
 Symbol name()
          Returns the name of the method.
 Table parameters()
          Returns the parameter list of the method which is normally a table of symbols.
 Closure wrap(Object lexicalScope, Object dynamicReceiver)
          Wrap the receiver method into a closure which packs together the code (method) and the scope (context) in which the code should be evaluated.
 
Methods inherited from interface edu.vub.at.objects.Object
super
 

Method Detail

wrap

Closure wrap(Object lexicalScope,
             Object dynamicReceiver)
Wrap the receiver method into a closure which packs together the code (method) and the scope (context) in which the code should be evaluated.

Parameters:
lexicalScope - the lexical scope in which the method was created. During method invocation, lexical lookup should proceed along this scope.
dynamicReceiver - the dynamic receiver (value of self) at the time the method is selected from an object.
Returns:
a closure wrapping this method.

apply

Object apply(Table arguments,
             Context ctx)
Applies the method to the given arguments in the given context. The context is usually supplied by a closure and is necessary in order to pair a method with its current receiver (its 'self').

The method itself is responsible for creating the appropriate 'call frame' or activation record in which to define temporary variables and parameter bindings.

Parameters:
arguments - the actual arguments, already eagerly evaluated.
ctx - the context in which to evaluate the method body, call frame not yet inserted.
Returns:
the value of evaluating the method body in a context derived from the given context.

applyInScope

Object applyInScope(Table arguments,
                    Context ctx)
Applies the method to the given arguments in the given context. The context is usually supplied by a closure and is necessary in order to pair a method with its current receiver (its 'self').

The method will use the given context 'as-is', and will *not* insert an additional call frame.

Parameters:
arguments - the actual arguments, already eagerly evaluated.
ctx - the context in which to evaluate the method body, to be used without inserting a call frame.
Returns:
the value of evaluating the method body in the given context.

name

Symbol name()
Returns the name of the method.

Note that all methods (defined using def name( ...args... ) { ... } or def foo: arg bar: arg { ... }) retain the name with which they were first bound. Literal blocks which may be created outside of a definition are implicitly named 'lambda'.

Returns:
an Symbol representing the name by which the method can be identified.

parameters

Table parameters()
Returns the parameter list of the method which is normally a table of symbols.

Returns:
an Table representing the parameter list of the method.

bodyExpression

Begin bodyExpression()
Returns the body of the method.

Returns:
an Begin representing the body of the method.

annotations

Table annotations()
Returns the annotations associated with the method.

Returns:
an Table containing the annotations of the method.