edu.vub.at.objects.natives
Class LexicalRoot

at.objects.natives.OBJLexicalRoot

 class LexicalRoot

The singleton instance of this class represents the lexical root of an actor. Since this lexical root is constant (it cannot be modified) and contains no mutable fields, it is possible to share a singleton instance of this class among all actors.

The lexical root is an object containing globally visible AmbientTalk native methods. Such methods include control structures such as if:then:else: but also object creation methods like object: and reflective constructs like reflect:. Furthermore, the lexical root is also the root of the lexical parent hierarchy for objects. This means that this object's mirror is responsible for ending recursive meta-level methods such as lookup and assignField.

Like any class whose instances represent native AmbientTalk objects, this class is a subclass of NativeATObject. This means that this class can use the typical protocol of native objects to implement base-level AmbientTalk methods as Java methods whose name is prefixed with base_.

Note that OBJLexicalRoot is a sentinel class. The actual object bound to the lexical root of an actor (accessible via the field root will be a normal AmbientTalk object whose lexical parent is this object. The real, empty, root object is local to each actor and is mutable. The definitions from the init.at file are added to that object.

Author:
smostinc, tvcutsem
See Also:
Serialized Form

Method Summary
 Object /()
          / evaluates to the global namespace.
 Boolean ==(Object comparand)
          Compare the receiver object to the root object.
 Numeric -(Numeric n)
          The unary - primitive.
 Boolean !(Boolean b)
          The unary !
 Number +(Number n)
          The unary + primitive.
 Object actor:(Closure closure)
          The actor: closure construct.
 Text asCode:(Object obj)
          The asCode: metaprogramming construct.
 Object clone:(Object original)
          The clone: language construct.
 Object defaultMirror()
          defaultMirror evaluates to the default mirror on objects.
 Object disconnect:(Object object)
          The disconnect: construct.
 Object do:if:(Closure body, Boolean condition)
          The do:if: control structure.
 Object do:unless:(Closure body, Boolean condition)
          The do:unless: control structure.
 Object eval:in:(AbstractGrammar ast, Object obj)
          The eval:in: metaprogramming construct.
 Object export:as:(Object object, TypeTag topic)
          The export: object as: topic construct.
 Object extend:with:(Object parent, Closure code)
          The extend:with: object creation primitive.
 Object extend:with:mirroredBy:(Object parent, Closure code, Object mirror)
          The extend:with:mirroredBy: object creation primitive.
 Object extend:with:taggedAs:(Object parent, Closure code, Table types)
          The extend:with:taggedAs: object creation primitive.
 Object extend:with:taggedAs:mirroredBy:(Object parent, Closure code, Table types, Object mirror)
          The extend:with:taggedAs:mirroredBy: object creation primitive.
 Boolean false()
          false evaluates to the unique boolean false object.
 Object foreach:in:(Closure body, Table tab)
          The foreach:in: control structure.
 Object handle:with:(TypeTag filter, Closure replacementCode)
          The handle: type with: { |e| replacementCode } construct.
 Object if:then:(Boolean cond, Closure consequent)
          The if:then: control structure.
 Object if:then:else:(Boolean cond, Closure consequent, Closure alternative)
          The if:then:else: control structure.
 Boolean is:taggedAs:(Object object, TypeTag type)
          The is: object taggedAs: type construct.
 Object isolate:(Closure code)
          The isolate: object creation primitive.
 Object jlobby()
          jlobby evaluates to the Java namespace root.
 Object let:(Closure body)
          The let: construct.
 Object lobby()
          lobby evaluates to the global namespace object.
 Object mirror:(Closure code)
          The mirror: object creation primitive.
 Object network()
          network evaluates to the unique network control object.
 Nil nil()
          nil evaluates to the nil object, which is the empty, dynamic parent of all AmbientTalk objects.
 Object object:(Closure code)
          The object: object creation primitive.
 Object object:childOf:extends:taggedAs:mirroredBy:(Closure code, Object parent, Boolean parentType, Table types, Object mirror)
          The object:childOf:extends:taggedAs:mirroredBy: object creation primitive.
 Object object:mirroredBy:(Closure code, Object mirror)
          The object:mirroredBy: object creation primitive.
 Object object:taggedAs:(Closure code, Table types)
          The object:taggedAs: object creation primitive.
 Object object:taggedAs:mirroredBy:(Closure code, Table types, Object mirror)
          The object:taggedAs:mirroredBy: object creation primitive.
 Text print:(Object obj)
          The print: metaprogramming construct.
 Nil raise:(Object anExceptionObject)
          The raise: exception construct.
 AbstractGrammar read:(Text source)
          The read: metaprogramming construct.
 Object reflect:(Object reflectee)
          The reflect: construct.
 ActorMirror reflectOnActor()
          reflectOnActor evaluates to the mirror on the actor executing this code.
 Table retract:(FarReference farReference)
          The retract: farReference construct.
 Object root()
          root evaluates to the global lexical scope object.
 Object share:with:(Object parent, Closure code)
          The share:with: object creation primitive.
 Object share:with:mirroredBy:(Object parent, Closure code, Object mirror)
          The share:with:mirroredBy: object creation primitive.
 Object share:with:taggedAs:(Object parent, Closure code, Table types)
          The share:with:taggedAs: object creation primitive.
 Object share:with:taggedAs:mirroredBy:(Object parent, Closure code, Table types, Object mirror)
          The share:with:taggedAs:mirroredBy: object creation primitive.
 Table tagsOf:(Object object)
          The tagsOf: object construct.
 Nil takeOffline:(Object object)
          The takeOffline: construct.
 Boolean true()
          true evaluates to the unique boolean true object.
 Object try:catch:using:(Closure tryBlock, TypeTag filter, Closure replacementCode)
          The try: { tryBlock} catch: type using: { |e| replacementCode } 'Syntactic sugar' for one "in-line", native handler.
 Object try:catch:using:catch:using:(Closure tryBlock, TypeTag filter1, Closure hdl1, TypeTag filter2, Closure hdl2)
          The try:catch:using:catch:using: construct.
 Object try:catch:using:catch:using:catch:using:(Closure tryBlock, TypeTag filter1, Closure hdl1, TypeTag filter2, Closure hdl2, TypeTag filter3, Closure hdl3)
          The try:catch:using:catch:using:catch:using: construct.
 Object try:catch:using:catch:using:catch:using:finally:(Closure tryBlock, TypeTag filter1, Closure hdl1, TypeTag filter2, Closure hdl2, TypeTag filter3, Closure hdl3, Closure finallyBlock)
          The try:catch:using:catch:using:catch:using:finally: construct.
 Object try:catch:using:catch:using:finally:(Closure tryBlock, TypeTag filter1, Closure hdl1, TypeTag filter2, Closure hdl2, Closure finallyBlock)
          The try:catch:using:catch:using:finally: construct.
 Object try:catch:using:finally:(Closure tryBlock, TypeTag filter, Closure replacementCode, Closure finallyBlock)
          The try: { tryBlock} catch: type using: { |e| replacementCode } finally: { finallyBlock } 'Syntactic sugar' for one "in-line", native handler.
 Object try:finally:(Closure tryBlock, Closure finallyBlock)
          The try: { tryBlock } finally: { finallyBlock } construct.
 Object try:using:(Closure tryBlock, Handler handler)
          The try: { tryBlock} using: handler construct.
 Object try:using:finally:(Closure tryBlock, Handler handler, Closure finallyBlock)
          The try: { tryBlock} using: handler finally: { finallyBlock } construct.
 Object try:using:using:(Closure tryBlock, Handler hdl1, Handler hdl2)
          The try: { tryBlock} using: handler1 using: handler2 construct.
 Object try:using:using:finally:(Closure tryBlock, Handler hdl1, Handler hdl2, Closure finallyBlock)
          The try: { tryBlock} using: handler1 using: handler2 finally: { finallyBlock } construct.
 Object try:using:using:using:(Closure tryBlock, Handler hdl1, Handler hdl2, Handler hdl3)
          The try: { tryBlock} using: hdl1 using: hdl2 using: hdl3 construct.
 Object try:using:using:using:finally:(Closure tryBlock, Handler hdl1, Handler hdl2, Handler hdl3, Closure finallyBlock)
          The try: { tryBlock} using: hdl1 using: hdl2 using: hdl3 finally: { finallyBlock } construct.
 Object try:usingHandlers:(Closure tryBlock, Table exceptionHandlers)
          The try: { tryBlock } usingHandlers: [ handler1, handler2, ... ] construct.
 Object try:usingHandlers:finally:(Closure tryBlock, Table exceptionHandlers, Closure finallyBlock)
          The try: { tryBlock } usingHandlers: [ handler1, handler2, ... ] finally: { finallyBlock } construct.
 Object when:discovered:(TypeTag topic, Closure handler)
          The when: topic discovered: handler construct.
 Object when:takenOffline:(FarReference farReference, Closure listener)
          The when: farReference takenOffline: construct.
 Object whenever:disconnected:(FarReference farReference, Closure listener)
          The whenever: farReference disconnected: listener construct.
 Object whenever:discovered:(TypeTag topic, Closure handler)
          The whenever: topic discovered: handler construct.
 Object whenever:reconnected:(FarReference farReference, Closure listener)
          The whenever: farReference reconnected: listener construct.
 Object while:do:(Closure condition, Closure body)
          The while:do: control structure.
 
Methods inherited from class edu.vub.at.objects.natives.NativeATObject
==, freeVariables, super
 
Methods inherited from interface edu.vub.at.objects.AbstractGrammar
freeVariables
 
Methods inherited from interface edu.vub.at.objects.Object
super
 

Method Detail

nil

public Nil nil()
nil evaluates to the nil object, which is the empty, dynamic parent of all AmbientTalk objects.


true

public Boolean true()
true evaluates to the unique boolean true object.


false

public Boolean false()
false evaluates to the unique boolean false object.


/

public Object /()
/ evaluates to the global namespace. It is simply an alias for lobby.

See Also:
base_lobby()

lobby

public Object lobby()
lobby evaluates to the global namespace object. For each name=path entry on AmbientTalk's object path, the lobby object contains a slot name bound to a namespace object bound to the directory referred to by path.

Accessing the lobby allows loading in AmbientTalk source code from external files.


root

public Object root()
root evaluates to the global lexical scope object. This is the top-level object in which the definitions of the file at/init/init.at are evaluated. All code is assumed to be "nested" in the lexical root, so all definitions of this object are lexically accessible.


jlobby

public Object jlobby()
jlobby evaluates to the Java namespace root. It is a special object which is part of the symbiosis infrastructure of AmbientTalk. jlobby acts like an object that has field names that correspond to Java package names. By selecting fields from this object, an appropriate Java package can be created from which a Java class can be accessed. Only the Java classes accessible in the Java classpath are accessible. Example: jlobby.java.util.Vector evaluates to a reference to the Java Vector class.


network

public Object network()
network evaluates to the unique network control object. It is a simple native object with two methods:


defaultMirror

public Object defaultMirror()
defaultMirror evaluates to the default mirror on objects. This is the mirror encapsulating the standard AmbientTalk object semantics. That is, it is a mirror with similar behaviour as the mirror created by executing: reflect: (object: { ... }). The default mirror is an object with a read-only base field that signifies the base-level object of this mirror. The main purpose of this object is to serve as a prototype whose methods can be overridden by custom mirrors. The syntax:
 mirror: { ... }
 
is syntactic sugar for:
 extend: defaultMirror with: { ... }
 
Note that the default mirror is typed with the /.at.types.Mirror type.


if:then:

public Object if:then:(Boolean cond,
                       Closure consequent)
The if:then: control structure. Usage:
if: cond then: consequent
pseudo-implementation:
cond.ifTrue: consequent
Note that the consequent parameter should be a closure, i.e. the caller is responsible for delaying the evaluation of the consequent!

Parameters:
cond - a boolean object
consequent - a closure containing the code to execute if the boolean is true
Returns:
if cond is true, the value of applying the consequent, nil otherwise

if:then:else:

public Object if:then:else:(Boolean cond,
                            Closure consequent,
                            Closure alternative)
The if:then:else: control structure. Usage:
if: cond then: consequent else: alternative
pseudo-implementation:
cond.ifTrue: consequent ifFalse: alternative
Note that the consequent and alternative parameters should be closures, i.e. the caller is responsible for delaying the evaluation of these arguments!

Parameters:
cond - a boolean object
consequent - a closure containing the code to execute if the boolean is true
alternative - a closure containing the code to execute if the boolean is false
Returns:
the value of consequent if the boolean is true, the value of the alternative otherwise.

while:do:

public Object while:do:(Closure condition,
                        Closure body)
The while:do: control structure. Usage:
while: condition do: body
pseudo-implementation:
condition.whileTrue: body
Note that both the condition and the body should be closures, because they represent pieces of code that have to be executed repeatedly. Because of traditional syntax, novice programmers are inclined to make the mistake of writing, e.g.:
while: (i < 10) do: { i := i + 1 }
Which is wrong because the first parameter should evaluate to a closure that itself returns a boolean value, not to a boolean value directly.

Parameters:
condition - a closure expected to return a boolean object
body - a closure containing the code to execute as long as the condition closure returns true
Returns:
if conditions is true at least once, the last value of body, nil otherwise.

foreach:in:

public Object foreach:in:(Closure body,
                          Table tab)
The foreach:in: control structure. Usage:
foreach: body in: table
pseudo-implementation:
table.each: body
Example: [1,2,3].each: { |i| system.println(i) }

Parameters:
body - a one-arity closure that is to be applied to each element of the table
tab - a table to apply the body closure to
Returns:
nil, by default

do:if:

public Object do:if:(Closure body,
                     Boolean condition)
The do:if: control structure. Usage:
do: body if: condition
pseudo-implementation:
condition.ifTrue: body
In Ruby, this kind of control structure is called a statement modifier.

Parameters:
body - a zero-argument closure to execute if the condition is true
condition - a boolean value
Returns:
the result of invoking body if the condition is true or nil if the condition is false

do:unless:

public Object do:unless:(Closure body,
                         Boolean condition)
The do:unless: control structure. Usage:
do: body unless: condition
pseudo-implementation:
condition.ifFalse: body
In Ruby, this kind of control structure is called a statement modifier. Example: do: { file.close() } unless: (nil == file)

Parameters:
body - a zero-argument closure to execute only if the condition is false
condition - a boolean value
Returns:
the result of invoking body if the condition is false, nil otherwise

let:

public Object let:(Closure body)
The let: construct. Usage:
let: { |var := value| body }
pseudo-implementation:
closure()
let: allows for the easy creation of temporary local variables. This construct should be used in conjunction with a closure that declares optional parameters. Because the closure will be invoked with zero arguments, all of the parameters will be given their corresponding default initial value. The parameters are defined local to the closure's body. AmbientTalk's let: behaves like Scheme's let* and letrec, i.e. the following is legal:
let: {
  |var1 := value1,
   var2 := var1,
   var3 := { ... var3() ... }|
  ...
}

Parameters:
body - a closure which is supposed to declare some optional parameters
Returns:
the result of invoking the body closure

actor:

public Object actor:(Closure closure)
The actor: closure construct. The semantics of actor creation is as follows:

Parameters:
closure - the closure whose parameters define lexical fields to be copied and whose method specifies the code of the new actor's behaviour object
Returns:
a far reference to the behaviour of the new actor

reflectOnActor

public ActorMirror reflectOnActor()
reflectOnActor evaluates to the mirror on the actor executing this code. The actor mirror is an object whose behaviour is consulted for operations such as creating and sending asynchronous messages or creating mirrors on other objects. It can be replaced by a custom mirror by means of the actor mirror's getExplicitActorMirror method.


export:as:

public Object export:as:(Object object,
                         TypeTag topic)
The export: object as: topic construct. Pseudo-implementation:
actor.provide(topic, object)
This construct enables the given object to become discoverable by objects in other actors by means of the topic type.

Parameters:
object - the object to export to remote actors' objects
topic - a type denoting the abstract 'publication topic' for this object's publication
Returns:
a publication object whose cancel method can be used to cancel the publication.

when:discovered:

public Object when:discovered:(TypeTag topic,
                               Closure handler)
The when: topic discovered: handler construct. Pseudo-implementation:
actor.require(topic, handler, false)
When an object is exported by another actor under topic, this construct triggers the given code, passing a reference to the exported object as argument to the closure. Once the code block has run once, it will not be triggered again.

Parameters:
topic - the abstract 'subscription topic' used to find an exported object
handler - a one-argument closure to apply to a discovered exported object
Returns:
a subscription object whose cancel method can be used to cancel the subscription, such that the handler will no longer be invoked. Beware, however, that at the time the subscription is cancelled, a request to apply the closure may already have been scheduled for execution by the current actor. This request is not cancelled by invoking the cancel method.

whenever:discovered:

public Object whenever:discovered:(TypeTag topic,
                                   Closure handler)
The whenever: topic discovered: handler construct. Pseudo-implementation:
actor.require(topic, handler, true)
When an object is exported by another actor under topic, this construct triggers the given code, passing a reference to the exported object as argument to the closure. The code block can be fired multiple times upon discovering multiple exported objects. To stop the block from triggering upon new publications, it must be explicitly cancelled

Parameters:
topic - the abstract 'subscription topic' used to find an exported object
handler - a one-argument closure to apply to any discovered exported object
Returns:
a subscription object whose cancel method can be used to cancel the subscription, such that the handler will no longer be invoked. Beware, however, that at the time the subscription is cancelled, a request to apply the closure may already have been scheduled for execution by the current actor. This request is not cancelled by invoking the cancel method.

whenever:disconnected:

public Object whenever:disconnected:(FarReference farReference,
                                     Closure listener)
The whenever: farReference disconnected: listener construct. When the far reference is broken due to network disconnections, triggers the zero-arity listener closure. It is possible to register listeners on local far references. These may trigger if the local actor takes its object offline. In this case, these listeners will trigger as well.

Parameters:
farReference - a native far reference
listener - a zero-arity closure to invoke if the far reference becomes disconnected
Returns:
a subscription object whose cancel method can be used to cancel future notifications of the listener.

whenever:reconnected:

public Object whenever:reconnected:(FarReference farReference,
                                    Closure listener)
The whenever: farReference reconnected: listener construct. When the remote reference is reinstated after a network disconnection, trigger the zero-arity listener. Although it is allowed to register these listeners on local far references, these are normally not invoked because the only possibility for a local far ref to become disconnected is because the object was taken offline, and this is a permanent disconnect.

Parameters:
farReference - a native far reference
listener - a zero-arity closure to invoke if the far reference becomes reconnected
Returns:
a subscription object whose cancel method can be used to cancel future notifications of the listener.

when:takenOffline:

public Object when:takenOffline:(FarReference farReference,
                                 Closure listener)
The when: farReference takenOffline: construct. When the (remote/local) far reference is broken because the object referenced was taken offline, trigger the code.

Parameters:
farReference - a native far reference
listener - a zero-arity closure to invoke if the referenced object has been taken offline.
Returns:
a subscription object whose cancel method can be used to cancel future notifications of the listener.

retract:

public Table retract:(FarReference farReference)
The retract: farReference construct. Retracts all currently unsent messages from the far reference's outbox. This has the side effect that the returned messages will not be sent automatically anymore, the programmer is responsible to explicitly resend all messages that were retracted but still need to be sent. Note that the returned messages are copies of the original.

Parameters:
farReference - the far reference of which to retract outgoing message sends
Returns:
a table containing copies of all messages that were sent to this far reference, but not yet transmitted by the far reference to its referent.

object:

public Object object:(Closure code)
The object: object creation primitive. This construct creates a new AmbientTalk object where: Example: object: { def x := 1; }

Pseudo-implementation:

object: code childOf: nil extends: false taggedAs: [] mirroredBy: defaultMirror
The closure used to initialize the object may contain formal parameters. The closure will always be invoked with its own mandatory formal parameters. E.g., a closure { |x| nil } is invoked as { |x| nil }(x). The net effect of this mechanic is that if x is a lexically visible variable at the object-creation site, the value of the variable will be copied into a copy with the same name which resides in the newly created object. This mechanic is primarily useful for copying surrounding variables within the object, e.g. for isolates which lose access to their surrounding scope.

Also, if the closure has optional parameters, they will always be triggered. The expressions to initialize the formal parameters are evaluated in the context of the closure's lexical scope but are added to the newly created object.

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

extend:with:

public Object extend:with:(Object parent,
                           Closure code)
The extend:with: object creation primitive. This construct creates a new AmbientTalk object where: Example: extend: parent with: { def x := 1; }

Pseudo-implementation:

object: code childOf: parent extends: true taggedAs: [] mirroredBy: defaultMirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

extend:with:taggedAs:

public Object extend:with:taggedAs:(Object parent,
                                    Closure code,
                                    Table types)
The extend:with:taggedAs: object creation primitive. This construct creates a new AmbientTalk object where: Example: extend: parent with: { def x := 1; } taggedAs: [foo,bar]

Pseudo-implementation:

object: code childOf: parent extends: true taggedAs: types mirroredBy: defaultMirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
types - a table of types with which to type the newly created object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

extend:with:mirroredBy:

public Object extend:with:mirroredBy:(Object parent,
                                      Closure code,
                                      Object mirror)
The extend:with:mirroredBy: object creation primitive. This construct creates a new AmbientTalk object where: Example: extend: parent with: { def x := 1; } mirroredBy: (mirror: {...})

Pseudo-implementation:

object: code childOf: parent extends: true taggedAs: [] mirroredBy: mirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
mirror - the mirror of the newly created mirage object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

extend:with:taggedAs:mirroredBy:

public Object extend:with:taggedAs:mirroredBy:(Object parent,
                                               Closure code,
                                               Table types,
                                               Object mirror)
The extend:with:taggedAs:mirroredBy: object creation primitive. This construct creates a new AmbientTalk object where: Example: extend: parent with: { def x := 1; } taggedAs: [foo,bar] mirroredBy: mirror

Pseudo-implementation:

object: code childOf: parent extends: true taggedAs: types mirroredBy: mirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
types - a table of types with which to type the newly created object.
the - mirror object of the newly created mirage object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

share:with:

public Object share:with:(Object parent,
                          Closure code)
The share:with: object creation primitive. This construct creates a new AmbientTalk object where: Example: share: parent with: { def x := 1; }

Pseudo-implementation:

object: code childOf: parent extends: false taggedAs: [] mirroredBy: defaultMirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

share:with:taggedAs:

public Object share:with:taggedAs:(Object parent,
                                   Closure code,
                                   Table types)
The share:with:taggedAs: object creation primitive. This construct creates a new AmbientTalk object where: Example: share: parent with: { def x := 1; } taggedAs: [foo,bar]

Pseudo-implementation:

object: code childOf: parent extends: false taggedAs: types mirroredBy: defaultMirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
types - a table of types with which to type the newly created object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

share:with:mirroredBy:

public Object share:with:mirroredBy:(Object parent,
                                     Closure code,
                                     Object mirror)
The share:with:mirroredBy: object creation primitive. This construct creates a new AmbientTalk object where: Example: share: parent with: { def x := 1; } mirroredBy: (mirror: {...})

Pseudo-implementation:

object: code childOf: parent extends: false taggedAs: [] mirroredBy: mirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
mirror - the mirror of the newly created mirage object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

share:with:taggedAs:mirroredBy:

public Object share:with:taggedAs:mirroredBy:(Object parent,
                                              Closure code,
                                              Table types,
                                              Object mirror)
The share:with:taggedAs:mirroredBy: object creation primitive. This construct creates a new AmbientTalk object where: Example: share: parent with: { def x := 1; } taggedAs: [foo,bar] mirroredBy: mirror

Pseudo-implementation:

object: code childOf: parent extends: false taggedAs: types mirroredBy: mirror

Parameters:
parent - the dynamic parent object of the newly created object.
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
types - a table of types with which to type the newly created object.
mirror - the mirror object of the newly created mirage object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

object:taggedAs:

public Object object:taggedAs:(Closure code,
                               Table types)
The object:taggedAs: object creation primitive. This construct creates a new AmbientTalk object where: Example: object: { def x := 1; } taggedAs: [foo,bar]

Pseudo-implementation:

object: code childOf: nil extends: false taggedAs: types mirroredBy: defaultMirror

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
types - a table of type tags with which to type the newly created object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

isolate:

public Object isolate:(Closure code)
The isolate: object creation primitive. This construct creates a new AmbientTalk object where: Example: isolate: { def x := 1; }

Pseudo-implementation:

object: code childOf: nil extends: false taggedAs: [/.at.types.Isolate] mirroredBy: defaultMirror
An isolate is an object without a proper lexical parent. It is as if the isolate is always defined at top-level. However, lexically visible variables can be retained by copying them into the isolate by means of formal parameters to the argument closure. Isolate objects are passed by-copy during inter-actor parameter and result passing.

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

mirror:

public Object mirror:(Closure code)
The mirror: object creation primitive. This construct creates a new AmbientTalk object where: Example: mirror: { def x := 1; }

Pseudo-implementation:

object: code childOf: defaultMirror extends: true taggedAs: [] mirroredBy: defaultMirror
This construct is mere syntactic sugar for creating an extension of the default mirror root. It follows that AmbientTalk mirrors are plain AmbientTalk objects. They simply need to implement the entire metaobject protocol, and the easiest means to achieve this is by extending the default mirror. Also keep in mind that the mirror is an extension object. This is important because the default mirror has state, being the base field that points to the base-level object being mirrorred. Hence, always make sure that, if overriding init, the parent's init method is invoked with the appropriate base value.

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

object:mirroredBy:

public Object object:mirroredBy:(Closure code,
                                 Object mirror)
The object:mirroredBy: object creation primitive. This construct creates a new AmbientTalk object where: Example: object: { def x := 1; } mirroredBy: (mirror: {...})

Pseudo-implementation:

object: code childOf: nil extends: false taggedAs: [] mirroredBy: mirror
This primitive allows the construction of so-called mirage objects which are AmbientTalk objects whose metaobject protocol behaviour is dictated by a custom mirror object.

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
mirror - the mirror prototype of the newly created mirage object, or a constructor closure.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

object:taggedAs:mirroredBy:

public Object object:taggedAs:mirroredBy:(Closure code,
                                          Table types,
                                          Object mirror)
The object:taggedAs:mirroredBy: object creation primitive. This construct creates a new AmbientTalk object where: Example: object: { def x := 1; } taggedAs: [foo,bar] mirroredBy: (mirror: {...})

Pseudo-implementation:

object: code childOf: nil extends: false taggedAs: types mirroredBy: mirror

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
types - a table of types with which to type the newly created object.
mirror - the mirror of the newly created mirage object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
base_object_(ATClosure), base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)

object:childOf:extends:taggedAs:mirroredBy:

public Object object:childOf:extends:taggedAs:mirroredBy:(Closure code,
                                                          Object parent,
                                                          Boolean parentType,
                                                          Table types,
                                                          Object mirror)
The object:childOf:extends:taggedAs:mirroredBy: object creation primitive. This construct creates a new AmbientTalk object where: Example: object: { def x := 1; } childOf: parent extends: true taggedAs: [foo,bar] mirroredBy: mirror

Pseudo-implementation:

let o = OBJECT(parent,code.lexicalParent,parentType,types);
  code.applyInScope(o, code.mandatoryPars);
  o
 

Parameters:
code - a closure containing both the code with which to initialize the object and the new object's lexical parent.
parent - the dynamic parent object of the newly created object.
parentType - a boolean denoting whether or not the object is an extension of its dynamic parent.
types - a table of types with which the newly created object should be typed.
mirror - the mirror of the newly created object.
Returns:
a new AmbientTalk object with the properties defined above.
See Also:
for more information about the properties of the passed closure.

reflect:

public Object reflect:(Object reflectee)
The reflect: construct. This construct returns a mirror on an object. pseudo-implementation:
actor.createMirror(reflectee)
An actor can change its default mirror creation policy by installing a new actor protocol that overrides createMirror.

Parameters:
reflectee - the object to reflect upon
Returns:
a mirror reflecting on the given object
See Also:
for the details about mirror creation on objects.

clone:

public Object clone:(Object original)
The clone: language construct. Returns a clone of an object. Care must be taken when cloning a mirror. If a mirror would simply be cloned using the regular cloning semantics, its base field would be shared between the clone and the original mirror (because of shallow copy semantics). However, the base object will still be tied to the original mirror, not the clone. Therefore, the clone: operator is implemented as follows:
def clone: obj {
   if: (is: obj taggedAs: Mirror) then: {
     reflect: (clone: obj.base)
   } else: {
     (reflect: obj).clone()
   }
 }
The default cloning semantics ensures that all fields of the object are shallow-copied. Because methods are immutable, a clone and its original object share their method dictionary, but whenever a change is made to the dictionary, the changer creates a local copy of the dictionary as to not modify any clones. Hence, each object is truly stand-alone and independent of its clone.

Parameters:
original - the object to copy
Returns:
a clone of the given object (default semantics results in a shallow copy)

takeOffline:

public Nil takeOffline:(Object object)
The takeOffline: construct. Removes an object from the export table of an actor. This ensures that the object is no longer remotely accessible. This method is the cornerstone of distributed garbage collection in AmbientTalk. When an object is taken offline, remote clients that would still access it perceive this as if the object had become permanently disconnected.

Returns:
nil.

disconnect:

public Object disconnect:(Object object)
The disconnect: construct. When an object is manually disconnected, remote clients will percieve this as if the object was physically disconnected. This allows per-object disconnects rather than per-actor disconnects.

Returns:
a disconnected object whose reconnect method can be used to reconnect (and re-publish) the disconnected object.

is:taggedAs:

public Boolean is:taggedAs:(Object object,
                            TypeTag type)
The is: object taggedAs: type construct.

Returns:
true if the given object is typed with the given type, false otherwise

tagsOf:

public Table tagsOf:(Object object)
The tagsOf: object construct.

Returns:
a table of all of the local types of an object.

try:finally:

public Object try:finally:(Closure tryBlock,
                           Closure finallyBlock)
The try: { tryBlock } finally: { finallyBlock } construct. Applies the tryBlock closure (to []). Whether the tryBlock raises an exception or not, the finallyBlock closure is guaranteed to be applied either after normal termination of the tryBlock or when an exception is propagated from the tryBlock.


try:usingHandlers:finally:

public Object try:usingHandlers:finally:(Closure tryBlock,
                                         Table exceptionHandlers,
                                         Closure finallyBlock)
The try: { tryBlock } usingHandlers: [ handler1, handler2, ... ] finally: { finallyBlock } construct. Applies the tryBlock closure (to []) and handles exceptions using the given exception handlers. Whether the tryBlock raises an exception or not, the finallyBlock closure is guaranteed to be applied either after the termination of the tryBlock or the execution of a fitting handler either before the exception is propagated if no matching handler is provided. This construct is the most general means of doing exception handling in AmbientTalk. The handlers given in the handler table represent first-class handler objects, which should respond to the canHandle message.

See Also:
for the interface to which a handler object has to adhere

try:usingHandlers:

public Object try:usingHandlers:(Closure tryBlock,
                                 Table exceptionHandlers)
The try: { tryBlock } usingHandlers: [ handler1, handler2, ... ] construct. Ad hoc code for tryBlocks which have an empty finally block

See Also:
base_try_usingHandlers_finally_(ATClosure, ATTable, ATClosure)

try:using:

public Object try:using:(Closure tryBlock,
                         Handler handler)
The try: { tryBlock} using: handler construct. Ad-hoc code for one exception handler.

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:using:finally:

public Object try:using:finally:(Closure tryBlock,
                                 Handler handler,
                                 Closure finallyBlock)
The try: { tryBlock} using: handler finally: { finallyBlock } construct. Ad-hoc code for one exception handler.

See Also:
base_try_usingHandlers_finally_(ATClosure, ATTable, ATClosure)

try:using:using:

public Object try:using:using:(Closure tryBlock,
                               Handler hdl1,
                               Handler hdl2)
The try: { tryBlock} using: handler1 using: handler2 construct. Ad-hoc code for two exception handlers.

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:using:using:finally:

public Object try:using:using:finally:(Closure tryBlock,
                                       Handler hdl1,
                                       Handler hdl2,
                                       Closure finallyBlock)
The try: { tryBlock} using: handler1 using: handler2 finally: { finallyBlock } construct. Ad-hoc code for two exception handlers.

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:using:using:using:

public Object try:using:using:using:(Closure tryBlock,
                                     Handler hdl1,
                                     Handler hdl2,
                                     Handler hdl3)
The try: { tryBlock} using: hdl1 using: hdl2 using: hdl3 construct. Ad-hoc code for three exception handlers

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:using:using:using:finally:

public Object try:using:using:using:finally:(Closure tryBlock,
                                             Handler hdl1,
                                             Handler hdl2,
                                             Handler hdl3,
                                             Closure finallyBlock)
The try: { tryBlock} using: hdl1 using: hdl2 using: hdl3 finally: { finallyBlock } construct. Ad-hoc code for three exception handlers.

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:catch:using:

public Object try:catch:using:(Closure tryBlock,
                               TypeTag filter,
                               Closure replacementCode)
The try: { tryBlock} catch: type using: { |e| replacementCode } 'Syntactic sugar' for one "in-line", native handler.

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:catch:using:finally:

public Object try:catch:using:finally:(Closure tryBlock,
                                       TypeTag filter,
                                       Closure replacementCode,
                                       Closure finallyBlock)
The try: { tryBlock} catch: type using: { |e| replacementCode } finally: { finallyBlock } 'Syntactic sugar' for one "in-line", native handler.

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:catch:using:catch:using:

public Object try:catch:using:catch:using:(Closure tryBlock,
                                           TypeTag filter1,
                                           Closure hdl1,
                                           TypeTag filter2,
                                           Closure hdl2)
The try:catch:using:catch:using: construct.
try: {
   tryBlock
 } catch: type using: { |e|
   replacementCode
 } catch: type2 using: { |e|
   replacementCode2
 }
'Syntactic sugar' for two in-line handlers

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:catch:using:catch:using:finally:

public Object try:catch:using:catch:using:finally:(Closure tryBlock,
                                                   TypeTag filter1,
                                                   Closure hdl1,
                                                   TypeTag filter2,
                                                   Closure hdl2,
                                                   Closure finallyBlock)
The try:catch:using:catch:using:finally: construct.
try: {
   tryBlock
 } catch: type using: { |e|
   replacementCode
 } catch: type2 using: { |e|
   replacementCode2
 } finally: {
   finalizationCode
 }
'Syntactic sugar' for two in-line handlers

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:catch:using:catch:using:catch:using:

public Object try:catch:using:catch:using:catch:using:(Closure tryBlock,
                                                       TypeTag filter1,
                                                       Closure hdl1,
                                                       TypeTag filter2,
                                                       Closure hdl2,
                                                       TypeTag filter3,
                                                       Closure hdl3)
The try:catch:using:catch:using:catch:using: construct.
try: {
   tryBlock
 } catch: type using: { |e|
   replacementCode
 } catch: type2 using: { |e|
   replacementCode2
 } catch: type3 using: { |e|
   replacementCode3
 }
'Syntactic sugar' for three in-line handlers

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

try:catch:using:catch:using:catch:using:finally:

public Object try:catch:using:catch:using:catch:using:finally:(Closure tryBlock,
                                                               TypeTag filter1,
                                                               Closure hdl1,
                                                               TypeTag filter2,
                                                               Closure hdl2,
                                                               TypeTag filter3,
                                                               Closure hdl3,
                                                               Closure finallyBlock)
The try:catch:using:catch:using:catch:using:finally: construct.
try: {
   tryBlock
 } catch: type using: { |e|
   replacementCode
 } catch: type2 using: { |e|
   replacementCode2
 } catch: type3 using: { |e|
   replacementCode3
 }
'Syntactic sugar' for three in-line handlers

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

handle:with:

public Object handle:with:(TypeTag filter,
                           Closure replacementCode)
The handle: type with: { |e| replacementCode } construct.

Returns:
a first-class handler from a filter prototype and some handler code.
See Also:
for the interface to which a handler object responds.

raise:

public Nil raise:(Object anExceptionObject)
The raise: exception construct. Raises an exception which can be caught by dynamically installed try-catch-using blocks.

See Also:
base_try_usingHandlers_(ATClosure, ATTable)

!

public Boolean !(Boolean b)
The unary ! primitive.
!b == b.not()

Parameters:
b - the boolean to negate.
Returns:
the negation of the boolean.

-

public Numeric -(Numeric n)
The unary - primitive.
-NUM(n) == 0 - n

Parameters:
n - a number or a fraction to negate.

+

public Number +(Number n)
The unary + primitive.
+NBR(n) == NBR(n)


read:

public AbstractGrammar read:(Text source)
The read: metaprogramming construct. Parses the given text string into an abstract syntax tree. Example: read: "x" => `x


eval:in:

public Object eval:in:(AbstractGrammar ast,
                       Object obj)
The eval:in: metaprogramming construct. Evaluates the given AST in the context of the given object, returning its value. Example: eval: `x in: object: { def x := 1 } => 1 This is a "dangerous" operation in the sense that lexical encapsulation of the given object can be violated.


print:

public Text print:(Object obj)
The print: metaprogramming construct. This construct invokes the object mirror's print method.

Returns:
a text string being a human-readable representation of the given object.

asCode:

public Text asCode:(Object obj)
The asCode: metaprogramming construct. This construct invokes the object mirror's asCode method.

Returns:
a text string being the source code representation of the given object.

==

public Boolean ==(Object comparand)
Compare the receiver object to the root object. the reason for this custom implementation: during the execution of this method, 'this' should refer to the global lexical scope object (the root), not to the OBJLexicalRoot instance. When invoking one of these methods lexically, the receiver is always 'root' For example, ==(obj) is equivalent to root == obj (or "root.==(obj)")

Overrides:
== in class at.objects.natives.NativeATObject