PageRenderTime 54ms CodeModel.GetById 13ms app.highlight 30ms RepoModel.GetById 1ms app.codeStats 1ms

/interpreter/tags/at2dist170907/src/edu/vub/at/objects/natives/OBJLexicalRoot.java

http://ambienttalk.googlecode.com/
Java | 1686 lines | 428 code | 112 blank | 1146 comment | 12 complexity | e6059201f74e48a900c95540ea6f9964 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/**
   2 * AmbientTalk/2 Project
   3 * OBJLexicalRoot.java created on 8-aug-2006 at 16:51:10
   4 * (c) Programming Technology Lab, 2006 - 2007
   5 * Authors: Tom Van Cutsem & Stijn Mostinckx
   6 * 
   7 * Permission is hereby granted, free of charge, to any person
   8 * obtaining a copy of this software and associated documentation
   9 * files (the "Software"), to deal in the Software without
  10 * restriction, including without limitation the rights to use,
  11 * copy, modify, merge, publish, distribute, sublicense, and/or
  12 * sell copies of the Software, and to permit persons to whom the
  13 * Software is furnished to do so, subject to the following
  14 * conditions:
  15 *
  16 * The above copyright notice and this permission notice shall be
  17 * included in all copies or substantial portions of the Software.
  18 *
  19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 * OTHER DEALINGS IN THE SOFTWARE.
  27 */
  28package edu.vub.at.objects.natives;
  29
  30import edu.vub.at.actors.ATActorMirror;
  31import edu.vub.at.actors.ATFarReference;
  32import edu.vub.at.actors.natives.ELActor;
  33import edu.vub.at.actors.natives.ELVirtualMachine;
  34import edu.vub.at.actors.natives.NATActorMirror;
  35import edu.vub.at.actors.natives.NATFarReference;
  36import edu.vub.at.actors.natives.Packet;
  37import edu.vub.at.actors.net.OBJNetwork;
  38import edu.vub.at.eval.Evaluator;
  39import edu.vub.at.exceptions.InterpreterException;
  40import edu.vub.at.exceptions.XUnassignableField;
  41import edu.vub.at.exceptions.XUndefinedSlot;
  42import edu.vub.at.objects.ATAbstractGrammar;
  43import edu.vub.at.objects.ATBoolean;
  44import edu.vub.at.objects.ATClosure;
  45import edu.vub.at.objects.ATHandler;
  46import edu.vub.at.objects.ATMethod;
  47import edu.vub.at.objects.ATNil;
  48import edu.vub.at.objects.ATNumber;
  49import edu.vub.at.objects.ATNumeric;
  50import edu.vub.at.objects.ATObject;
  51import edu.vub.at.objects.ATTable;
  52import edu.vub.at.objects.ATText;
  53import edu.vub.at.objects.ATTypeTag;
  54import edu.vub.at.objects.coercion.NativeTypeTags;
  55import edu.vub.at.objects.grammar.ATAssignmentSymbol;
  56import edu.vub.at.objects.grammar.ATSymbol;
  57import edu.vub.at.objects.mirrors.NATMirage;
  58import edu.vub.at.objects.mirrors.OBJMirrorRoot;
  59import edu.vub.at.parser.NATParser;
  60
  61/**
  62 * The singleton instance of this class represents the lexical root of an actor.
  63 * Since this lexical root is constant (it cannot be modified) and contains no mutable fields,
  64 * it is possible to share a singleton instance of this class among all actors.
  65 * <p>
  66 * The lexical root is an object containing globally visible AmbientTalk native methods.
  67 * Such methods include control structures such as <tt>if:then:else:</tt>
  68 * but also object creation methods like <tt>object:</tt> and reflective constructs
  69 * like <tt>reflect:</tt>.
  70 * 
  71 * Furthermore, the lexical root is also the root of the lexical parent hierarchy for objects.
  72 * This means that this object's mirror is responsible for ending recursive meta-level methods
  73 * such as <tt>lookup</tt> and <tt>assignField</tt>.
  74 * <p>
  75 * Like any class whose instances represent native AmbientTalk objects, this class is a subclass
  76 * of {@link NativeATObject}. This means that this class can use the typical protocol of native objects
  77 * to implement base-level AmbientTalk methods as Java methods whose name is prefixed with
  78 * <tt>base_</tt>.
  79 * <p>
  80 * Note that OBJLexicalRoot is a <i>sentinel</i> class. The actual object bound to the
  81 * lexical root of an actor (accessible via the field <tt>root</tt> will be a normal
  82 * AmbientTalk object whose lexical parent is this object.
  83 * The real, empty, root object is local to each actor and is mutable. The definitions
  84 * from the <tt>init.at</tt> file are added to that object.
  85 * 
  86 * @author smostinc
  87 * @author tvcutsem
  88 */
  89public final class OBJLexicalRoot extends NATByCopy {
  90	
  91	/**
  92	 * The singleton instance of the sentinel lexical root
  93	 */
  94	static public final OBJLexicalRoot _INSTANCE_ = new OBJLexicalRoot();
  95	
  96	/**
  97	 * Constructor made private for singleton design pattern
  98	 */
  99	private OBJLexicalRoot() { }
 100	
 101	/**
 102	 * The lexical root has a special lexical parent object which ends the recursion
 103	 * along the lexical lookup chain. These methods cannot be implemented
 104	 * directly in this class because this class still implements useful
 105	 * <tt>base_</tt> Java methods which have to be invoked by means of the
 106	 * implementations defined in {@link NativeATObject}.
 107	 */
 108	private final NativeATObject lexicalSentinel_ = new NATByCopy() {
 109		// METHODS THAT END THE LEXICAL LOOKUP CHAIN
 110		
 111		public ATObject impl_callAccessor(ATSymbol selector, ATTable arguments) throws InterpreterException {
 112			throw new XUndefinedSlot("variable access", selector.toString());
 113		}
 114
 115		public ATObject impl_callMutator(ATAssignmentSymbol selector, ATTable arguments) throws InterpreterException {
 116			throw new XUnassignableField(selector.toString());
 117		}	
 118		
 119		public ATObject impl_callField(ATSymbol selector) throws InterpreterException {
 120			throw new XUndefinedSlot("variable access", selector.toString());
 121		}
 122		
 123		public ATClosure impl_lookupAccessor(final ATSymbol selector) throws InterpreterException {
 124			throw new XUndefinedSlot("accessor", selector.toString());
 125		}
 126
 127		public ATClosure impl_lookupMutator(ATAssignmentSymbol selector) throws InterpreterException {
 128			throw new XUnassignableField(selector.toString());
 129		}
 130
 131		public NATText meta_print() throws InterpreterException {
 132			return NATText.atValue("lexicalrootsentinel");
 133		}
 134	};
 135	
 136	public ATObject impl_lexicalParent() {
 137		return lexicalSentinel_;
 138	}
 139	
 140	/* -----------------------
 141	 * -- Primitive Methods --
 142	 * ----------------------- */
 143	
 144	/* ===============================================================================
 145	 * NOTE: the code below has been replaced by dedicated syntax and AST elements.
 146	 * However, the skeleton of this code may still prove useful in the future, if
 147	 * we ever plan to implement all base_ native methods as true AmbientTalk methods
 148	 * (i.e. as PrimitiveMethod instances).
 149	 * ===============================================================================
 150	 */
 151	
 152	
 153	/*
 154	private static final AGSymbol _IMPORT_NAME_ = AGSymbol.jAlloc("import:");
 155	private static final AGSymbol _IMPORT_ALIAS_NAME_ = AGSymbol.jAlloc("import:alias:");
 156	private static final AGSymbol _IMPORT_EXCLUDE_NAME_ = AGSymbol.jAlloc("import:exclude:");
 157	private static final AGSymbol _IMPORT_ALIAS_EXCLUDE_NAME_ = AGSymbol.jAlloc("import:alias:exclude:");
 158	
 159	private static final AGSymbol _SRC_PARAM_ = AGSymbol.jAlloc("sourceObject");
 160	private static final AGSymbol _ALIAS_PARAM_ = AGSymbol.jAlloc("aliases");
 161	private static final AGSymbol _EXCLUDE_PARAM_ = AGSymbol.jAlloc("exclude");
 162	*/
 163	
 164	
 165	/*protected static final PrimitiveMethod _PRIM_IMPORT_ = new PrimitiveMethod(_IMPORT_NAME_, NATTable.atValue(new ATObject[] { _SRC_PARAM_ })) {
 166		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 167			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 168			  return performImport(sourceObject, ctx, new Hashtable(), OBJLexicalRoot.getDefaultExcludedSlots());
 169		}
 170	};*/
 171	
 172	/**
 173	 * def import: sourceObject alias: [ `oldname -> `newname , ... ]
 174	 */
 175	/*protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_ = new PrimitiveMethod(_IMPORT_ALIAS_NAME_, NATTable.atValue(new ATObject[] { _SRC_PARAM_, _ALIAS_PARAM_ })) {
 176		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 177			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 178			  ATObject aliases = arguments.base_at(NATNumber.atValue(2));
 179			  return performImport(sourceObject, ctx, preprocessAliases(aliases.base_asTable()), OBJLexicalRoot.getDefaultExcludedSlots());
 180		}
 181	};*/
 182	
 183	/**
 184	 * def import: sourceObject excludes: [ `name1, `name2, ... ]
 185	 */
 186	/*protected static final PrimitiveMethod _PRIM_IMPORT_EXCLUDE_ = new PrimitiveMethod(_IMPORT_EXCLUDE_NAME_, NATTable.atValue(new ATObject[] { _SRC_PARAM_, _EXCLUDE_PARAM_ })) {
 187		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 188			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 189			  ATObject exclusions = arguments.base_at(NATNumber.atValue(2));
 190			  return performImport(sourceObject, ctx, new Hashtable(), preprocessExcludes(exclusions.base_asTable()));
 191		}
 192	};*/
 193	
 194	/**
 195	 * def import: sourceObject alias: [ `oldname -> `newname, ... ] excludes: [ `name1, `name2, ... ]
 196	 */
 197	/*protected static final PrimitiveMethod _PRIM_IMPORT_ALIAS_EXCLUDE_ = new PrimitiveMethod(_IMPORT_ALIAS_EXCLUDE_NAME_,
 198			                                                                                 NATTable.atValue(new ATObject[] { _SRC_PARAM_, _ALIAS_PARAM_, _EXCLUDE_PARAM_ })) {
 199		public ATObject base_apply(ATTable arguments, ATContext ctx) throws InterpreterException {
 200			  ATObject sourceObject = arguments.base_at(NATNumber.ONE);
 201			  ATObject aliases = arguments.base_at(NATNumber.atValue(2));
 202			  ATObject exclusions = arguments.base_at(NATNumber.atValue(3));
 203			  return performImport(sourceObject, ctx, preprocessAliases(aliases.base_asTable()), preprocessExcludes(exclusions.base_asTable()));
 204		}
 205	};*/
 206	
 207	/**
 208	 * Invoked whenever a new true AmbientTalk object is created that should
 209	 * represent the root. This gives the lexical root a chance to install its
 210	 * primitive methods.
 211	 */
 212	/*public static void initializeRoot(NATObject root) {
 213		try {
 214			// add import: native
 215			root.meta_addMethod(_PRIM_IMPORT_);
 216			// add import:alias: native
 217			root.meta_addMethod(_PRIM_IMPORT_ALIAS_);
 218			// add import:exclude: native
 219			root.meta_addMethod(_PRIM_IMPORT_EXCLUDE_);
 220			// add import:alias:exclude: native
 221			root.meta_addMethod(_PRIM_IMPORT_ALIAS_EXCLUDE_);
 222		} catch (InterpreterException e) {
 223			Logging.Init_LOG.fatal("Failed to initialize the root!", e);
 224		}
 225	}*/
 226	
 227	/* ----------------------
 228	 * -- Global variables --
 229	 * ---------------------- */
 230	
 231	/**
 232	 * <tt>nil</tt> evaluates to the nil object, which is
 233	 * the empty, dynamic parent of all AmbientTalk objects. 
 234	 */
 235	public ATNil base_nil() {
 236		return OBJNil._INSTANCE_;
 237	}
 238	
 239	/**
 240	 * <tt>true</tt> evaluates to the unique boolean true object.
 241	 */
 242	public ATBoolean base_true() {
 243		return NATBoolean._TRUE_;
 244	}
 245	
 246	/**
 247	 * <tt>false</tt> evaluates to the unique boolean false object.
 248	 */
 249	public ATBoolean base_false() {
 250		return NATBoolean._FALSE_;
 251	}
 252	
 253	/**
 254	 * <tt>/</tt> evaluates to the global namespace. It is
 255	 * simply an alias for <tt>lobby</tt>.
 256	 * @see #base_lobby()
 257	 */
 258	public ATObject base__opdiv_() {
 259		return base_lobby();
 260	}
 261	
 262	/**
 263	 * <tt>lobby</tt> evaluates to the global namespace object.
 264	 * For each <tt>name=path</tt> entry on AmbientTalk's
 265	 * <i>object path</i>, the lobby object contains a slot
 266	 * <tt>name</tt> bound to a namespace object bound to
 267	 * the directory referred to by <tt>path</tt>.
 268	 * <p>
 269	 * Accessing the lobby allows loading in AmbientTalk source code
 270	 * from external files.
 271	 */
 272	public ATObject base_lobby() {
 273		return Evaluator.getLobbyNamespace();
 274	}
 275	
 276	/**
 277	 * <tt>root</tt> evaluates to the global lexical scope object.
 278	 * This is the top-level object in which the definitions of
 279	 * the file <tt>at/init/init.at</tt> are evaluated. All code
 280	 * is assumed to be "nested" in the lexical root, so all definitions
 281	 * of this object are lexically accessible.
 282	 */
 283	public ATObject base_root() {
 284		return Evaluator.getGlobalLexicalScope();
 285	}
 286	
 287	/**
 288	 * <tt>jlobby</tt> evaluates to the Java namespace root. It is a
 289	 * special object which is part of the symbiosis infrastructure of
 290	 * AmbientTalk. <tt>jlobby</tt> acts like an object that has field
 291	 * names that correspond to Java package names. By selecting fields
 292	 * from this object, an appropriate Java package can be created
 293	 * from which a Java class can be accessed. Only the Java classes
 294	 * accessible in the Java classpath are accessible.
 295	 * 
 296	 * Example:
 297	 * <code>jlobby.java.util.Vector</code> evaluates to a reference to
 298	 * the Java <tt>Vector</tt> class.
 299	 */
 300	public ATObject base_jlobby() {
 301		return Evaluator.getJLobbyRoot();
 302	}
 303
 304	/**
 305	 * <tt>network</tt> evaluates to the unique network control object.
 306	 * It is a simple native object with two methods:
 307	 * <ul>
 308	 *  <li><tt>network.online()</tt> makes the interpreter go online. This allows
 309	 *  publications of local actors to be discovered by remote objects and vice versa.
 310	 *  <li><tt>network.offline()</tt> makes the interpreter go offline. All
 311	 *  remote references to remote objects will become disconnected.
 312	 * </ul>
 313	 */
 314	public ATObject base_network() {
 315		return OBJNetwork._INSTANCE_;
 316	}
 317	
 318	/**
 319	 * <tt>defaultMirror</tt> evaluates to the default mirror on objects. This
 320	 * is the mirror encapsulating the standard AmbientTalk object semantics.
 321	 * That is, it is a mirror with similar behaviour as the mirror created by
 322	 * executing: <code>reflect: (object: { ... })</code>.
 323	 * 
 324	 * The default mirror is an object with a read-only <tt>base</tt> field
 325	 * that signifies the base-level object of this mirror. The main purpose
 326	 * of this object is to serve as a prototype whose methods can be overridden
 327	 * by custom mirrors. The syntax:
 328	 * <pre>
 329	 * mirror: { ... }
 330	 * </pre>
 331	 * is syntactic sugar for:
 332	 * <pre>
 333	 * extend: defaultMirror with: { ... }
 334	 * </pre>
 335	 * 
 336	 * Note that the default mirror is typed with the <tt>/.at.types.Mirror</tt> type.
 337	 */
 338	public ATObject base_defaultMirror() {
 339		return Evaluator.getMirrorRoot();
 340	}
 341	
 342	/* ------------------------
 343	 * -- Control Structures --
 344	 * ------------------------ */
 345	
 346	/**
 347	 * The <tt>if:then:</tt> control structure. Usage:
 348	 *  <pre>if: cond then: consequent</pre>
 349	 * 
 350	 * pseudo-implementation:
 351	 * <pre>cond.ifTrue: consequent</pre>
 352	 * 
 353	 * Note that the consequent parameter should be a <i>closure</i>, i.e.
 354	 * the caller is responsible for delaying the evaluation of the consequent!
 355	 * 
 356	 * @param cond a boolean object
 357	 * @param consequent a closure containing the code to execute if the boolean is true
 358	 * @return if <tt>cond</tt> is true, the value of applying the consequent, <tt>nil</tt> otherwise
 359	 */
 360	public ATObject base_if_then_(ATBoolean cond, ATClosure consequent) throws InterpreterException {
 361		return cond.base_ifTrue_(consequent);
 362	}
 363	
 364	/**
 365	 * The <tt>if:then:else:</tt> control structure. Usage:
 366	 *  <pre>if: cond then: consequent else: alternative</pre>
 367	 * 
 368	 * pseudo-implementation:
 369	 * <pre>cond.ifTrue: consequent ifFalse: alternative</pre>
 370	 * 
 371	 * Note that the consequent and alternative parameters should be <i>closures</i>, i.e.
 372	 * the caller is responsible for delaying the evaluation of these arguments!
 373	 * 
 374	 * @param cond a boolean object
 375	 * @param consequent a closure containing the code to execute if the boolean is true
 376	 * @param alternative a closure containing the code to execute if the boolean is false
 377	 * @return the value of consequent if the boolean is true, the value of the alternative otherwise.
 378	 */
 379	public ATObject base_if_then_else_(ATBoolean cond, ATClosure consequent, ATClosure alternative) throws InterpreterException {
 380		return cond.base_ifTrue_ifFalse_(consequent, alternative);
 381	}
 382	
 383	/**
 384	 * The <tt>while:do:</tt> control structure. Usage:
 385	 * <pre>while: condition do: body</pre>
 386	 * 
 387	 * pseudo-implementation:
 388	 * <pre>condition.whileTrue: body</pre>
 389	 * 
 390	 * Note that <i>both</i> the condition and the body should be <i>closures</i>, because
 391	 * they represent pieces of code that have to be executed repeatedly. Because of traditional
 392	 * syntax, novice programmers are inclined to make the mistake of writing, e.g.:
 393	 * <pre>while: (i < 10) do: { i := i + 1 }</pre>
 394	 * Which is wrong because the first parameter should evaluate to a closure that itself
 395	 * returns a boolean value, not to a boolean value directly.
 396	 * 
 397	 * @param condition a closure expected to return a boolean object
 398	 * @param body a closure containing the code to execute as long as the condition closure returns true
 399	 * @return if conditions is true at least once, the last value of body, <tt>nil</tt> otherwise.
 400	 */
 401	public ATObject base_while_do_(ATClosure condition, ATClosure body) throws InterpreterException {
 402		return condition.base_whileTrue_(body);
 403	}
 404	
 405	/**
 406	 * The <tt>foreach:in:</tt> control structure. Usage:
 407	 * 
 408	 * <pre>foreach: body in: table</pre>
 409	 * 
 410	 * pseudo-implementation:
 411	 * <pre>table.each: body</pre>
 412	 * 
 413	 * Example: <code>[1,2,3].each: { |i| system.println(i) }</code>
 414	 * 
 415	 * @param body a one-arity closure that is to be applied to each element of the table
 416	 * @param tab a table to apply the body closure to
 417	 * @return <tt>nil</tt>, by default
 418	 */
 419	public ATObject base_foreach_in_(ATClosure body, ATTable tab) throws InterpreterException {
 420		return tab.base_each_(body);
 421	}
 422
 423	/**
 424	 * The <tt>do:if:</tt> control structure. Usage:
 425	 * <pre>do: body if: condition</pre>
 426	 * 
 427	 * pseudo-implementation:
 428	 * <pre>condition.ifTrue: body</pre>
 429	 *
 430	 * In Ruby, this kind of control structure is called a <i>statement modifier</i>.
 431	 * 
 432	 * @param body a zero-argument closure to execute if the condition is true
 433	 * @param condition a boolean value
 434	 * @return the result of invoking body if the condition is true or nil if the
 435	 * condition is false
 436	 */
 437	public ATObject base_do_if_(ATClosure body, ATBoolean condition) throws InterpreterException {
 438		return condition.base_ifTrue_(body);
 439	}
 440	
 441	/**
 442	 * The <tt>do:unless:</tt> control structure. Usage:
 443	 * <pre>do: body unless: condition</pre>
 444	 * 
 445	 * pseudo-implementation:
 446	 * <pre>condition.ifFalse: body</pre>
 447	 *
 448	 * In Ruby, this kind of control structure is called a <i>statement modifier</i>.
 449	 * Example: <code>do: { file.close() } unless: (nil == file)</code>
 450	 * 
 451	 * @param body a zero-argument closure to execute only if the condition is false
 452	 * @param condition a boolean value
 453	 * @return the result of invoking body if the condition is false, nil otherwise
 454	 */
 455	public ATObject base_do_unless_(ATClosure body, ATBoolean condition) throws InterpreterException {
 456		return condition.base_ifFalse_(body);
 457	}
 458	
 459	/**
 460	 * The <tt>let:</tt> construct. Usage:
 461	 * <pre>let: { |var := value| body }</pre>
 462	 * 
 463	 * pseudo-implementation:
 464	 * <pre>closure()</pre>
 465	 * 
 466	 * <tt>let:</tt> allows for the easy creation of temporary local variables.
 467	 * This construct should be used in conjunction with a closure that declares optional
 468	 * parameters. Because the closure will be invoked with zero arguments, all of the
 469	 * parameters will be given their corresponding default initial value. The parameters
 470	 * are defined local to the closure's body.
 471	 * 
 472	 * AmbientTalk's <tt>let:</tt> behaves like Scheme's <tt>let*</tt> and <tt>letrec</tt>,
 473	 * i.e. the following is legal:
 474	 * <pre>let: {
 475	 *  |var1 := value1,
 476	 *   var2 := var1,
 477	 *   var3 := { ... var3() ... }|
 478	 *  ...
 479	 *}</pre>
 480	 * 
 481	 * @param body a closure which is supposed to declare some optional parameters
 482	 * @return the result of invoking the body closure
 483	 */
 484	public ATObject base_let_(ATClosure body) throws InterpreterException {
 485		return body.base_apply(NATTable.EMPTY);
 486	}
 487	
 488	/* ------------------------------------------
 489	 * -- Actor Creation and accessing Methods --
 490	 * ------------------------------------------ */
 491	
 492	/**
 493	 * The <tt>actor: closure</tt> construct.
 494	 *  
 495	 * The semantics of actor creation is as follows:
 496	 * <ul>
 497	 *  <li> Mandatory parameters to the block of initialization code are treated as lexically visible
 498	 *   variables that have to remain available in the new actor behaviour. Hence, these variables
 499	 *   are evaluated to values immediately at creation-time and parameter-passed to the new actor.
 500	 *  <li> The closure containing the initialization code is unpacked, its lexical scope is disregarded
 501	 *   and the unwrapped method is serialized and sent to the new actor, which can use it to
 502	 *   initialize his behaviour object.
 503	 *  <li>The creating actor waits for the created actor to spawn a new behaviour and to return a far
 504	 *   reference to this behaviour. From that point on, the creating actor can run in parallel with
 505	 *   the created actor, which only then evaluates the initialization code to initialize its behaviour.
 506	 * </ul>
 507	 * 
 508	 * @param closure the closure whose parameters define lexical fields to be copied and whose
 509	 * method specifies the code of the new actor's behaviour object
 510	 * @return a far reference to the behaviour of the new actor
 511	 */
 512	public ATObject base_actor_(ATClosure closure) throws InterpreterException {
 513		ATMethod method = closure.base_method();
 514		NATTable copiedBindings = Evaluator.evalMandatoryPars(
 515				method.base_parameters(),
 516				closure.base_context());
 517		
 518		Packet serializedBindings = new Packet("actor-bindings", copiedBindings);
 519		Packet serializedInitCode = new Packet("actor-initcode", method);
 520		ELVirtualMachine host = ELVirtualMachine.currentVM();
 521		return NATActorMirror.createActor(host, serializedBindings, serializedInitCode, new NATActorMirror(host));
 522	}
 523	
 524	/**
 525	 * <tt>actor</tt> evaluates to the mirror on the actor executing this code.
 526	 * The actor mirror is an object whose behaviour is consulted for operations
 527	 * such as creating and sending asynchronous messages or creating mirrors on
 528	 * other objects. It can be replaced by a custom mirror by means of the actor
 529	 * mirror's <tt>install:</tt> primitive.
 530	 */
 531	public ATActorMirror base_actor() throws InterpreterException {
 532		return ELActor.currentActor().getActorMirror();
 533	}
 534	
 535	/**
 536	 * The <tt>export: object as: topic</tt> construct. Pseudo-implementation:
 537	 * <pre>actor.provide(topic, object)</pre>
 538	 * 
 539	 * This construct enables the given object to become discoverable by objects
 540	 * in other actors by means of the topic type.
 541	 * 
 542	 * @param object the object to export to remote actors' objects
 543	 * @param topic a type denoting the abstract 'publication topic' for this object's publication
 544	 * @return a publication object whose <tt>cancel</tt> method can be used to cancel the publication.
 545	 */
 546	public ATObject base_export_as_(ATObject object, ATTypeTag topic) throws InterpreterException {
 547		return ELActor.currentActor().getActorMirror().base_provide(topic, object);
 548	}
 549	
 550	/**
 551	 * The <tt>when: topic discovered: handler</tt> construct. Pseudo-implementation:
 552	 * <pre>actor.require(topic, handler, false)</pre>
 553	 * 
 554	 * When an object is exported by <i>another</i> actor under topic, this construct triggers
 555	 * the given code, passing a reference to the exported object as argument to the closure.
 556	 * 
 557	 * Once the code block has run once, it will not be triggered again.
 558	 * 
 559	 * @param topic the abstract 'subscription topic' used to find an exported object
 560	 * @param handler a one-argument closure to apply to a discovered exported object
 561	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel the subscription,
 562	 * such that the handler will no longer be invoked. Beware, however, that at the time the
 563	 * subscription is cancelled, a request to apply the closure may already have been scheduled
 564	 * for execution by the current actor. This request is not cancelled by invoking the <tt>cancel</tt> method.
 565	 */
 566	public ATObject base_when_discovered_(ATTypeTag topic, ATClosure handler) throws InterpreterException {
 567		return ELActor.currentActor().getActorMirror().base_require(topic, handler, NATBoolean._FALSE_);
 568	}
 569	
 570	/**
 571	 * The <tt>whenever: topic discovered: handler</tt> construct. Pseudo-implementation:
 572	 * <pre>actor.require(topic, handler, true)</pre>
 573	 * 
 574	 * When an object is exported by <i>another</i> actor under topic, this construct triggers
 575	 * the given code, passing a reference to the exported object as argument to the closure.
 576	 * 
 577	 * The code block can be fired multiple times upon discovering multiple exported objects.
 578	 * To stop the block from triggering upon new publications, it must be explicitly cancelled
 579	 * 
 580	 * @param topic the abstract 'subscription topic' used to find an exported object
 581	 * @param handler a one-argument closure to apply to any discovered exported object
 582	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel the subscription,
 583	 * such that the handler will no longer be invoked. Beware, however, that at the time the
 584	 * subscription is cancelled, a request to apply the closure may already have been scheduled
 585	 * for execution by the current actor. This request is not cancelled by invoking the <tt>cancel</tt> method.
 586	 */
 587	public ATObject base_whenever_discovered_(ATTypeTag topic, ATClosure handler) throws InterpreterException {
 588		return ELActor.currentActor().getActorMirror().base_require(topic, handler, NATBoolean._TRUE_);
 589	}
 590	
 591	/**
 592	 * The <tt>when: farReference disconnected: listener</tt> construct.
 593	 * When the far reference is broken due to network disconnections, triggers the zero-arity listener
 594	 * closure. It is possible to register listeners on local far references. These may trigger if the
 595	 * local actor takes its object offline. In this case, these listeners will trigger as well.
 596	 * 
 597	 * @param farReference a native far reference
 598	 * @param listener a zero-arity closure to invoke if the far reference becomes disconnected
 599	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel future
 600	 * notifications of the listener.
 601	 */
 602	public ATObject base_when_disconnected_(ATFarReference farReference, ATClosure listener) throws InterpreterException {
 603		farReference.asNativeFarReference().addDisconnectionListener(listener);
 604		return new NATFarReference.NATDisconnectionSubscription(farReference.asNativeFarReference(), listener);
 605	}
 606	
 607	/**
 608	 * The <tt>when: farReference reconnected: listener</tt> construct.
 609	 * When the remote reference is reinstated after a network disconnection, trigger the zero-arity
 610	 * listener. Although it is allowed to register these listeners on local far references,
 611	 * these are normally not invoked because the only possibility for a local far ref to become
 612	 * disconnected is because the object was taken offline, and this is a permanent disconnect.
 613	 * 
 614	 * @param farReference a native far reference
 615	 * @param listener a zero-arity closure to invoke if the far reference becomes reconnected
 616	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel future
 617	 * notifications of the listener.
 618	 */
 619	public ATObject base_when_reconnected_(ATFarReference farReference, ATClosure listener) throws InterpreterException {
 620		farReference.asNativeFarReference().addReconnectionListener(listener);
 621		return new NATFarReference.NATReconnectionSubscription(farReference.asNativeFarReference(), listener);
 622	}
 623	
 624	/**
 625	 * The <tt>when: farReference takenOffline:</tt> construct.
 626	 *  When the (remote/local) far reference is broken because the object referenced was 
 627	 *  taken offline, trigger the code.
 628	 *  
 629	 * @param farReference a native far reference
 630	 * @param listener a zero-arity closure to invoke if the referenced object has been taken offline.
 631	 * @return a subscription object whose <tt>cancel</tt> method can be used to cancel future
 632	 * notifications of the listener.
 633	 */
 634	public ATObject base_when_takenOffline_(ATFarReference farReference, ATClosure listener) throws InterpreterException {
 635		farReference.asNativeFarReference().addTakenOfflineListener(listener);
 636		return new NATFarReference.NATExpiredSubscription(farReference.asNativeFarReference(), listener);
 637	}
 638	
 639
 640	/**
 641	 * The <tt>retract: farReference</tt> construct. 
 642	 * Retracts all currently unsent messages from the far reference's outbox.
 643	 * This has the side effect that the returned messages will <b>not</b> be sent
 644	 * automatically anymore, the programmer is responsible to explicitly resend
 645	 * all messages that were retracted but still need to be sent.
 646	 *  
 647	 * Note that the returned messages are copies of the original.
 648	 * @param farReference the far reference of which to retract outgoing message sends
 649	 * @return a table containing copies of all messages that were sent to this far reference, but
 650	 * not yet transmitted by the far reference to its referent.
 651	 */
 652	public ATTable base_retract_(ATFarReference farReference) throws InterpreterException {
 653		return farReference.meta_retractUnsentMessages();
 654	}
 655	
 656	/* -----------------------------
 657	 * -- Object Creation Methods --
 658	 * ----------------------------- */
 659	
 660	/**
 661	 * The <tt>object:</tt> object creation primitive.
 662	 * This construct creates a new AmbientTalk object where:
 663	 * <ul>
 664	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 665	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 666	 *  <li>The object's <b>dynamic parent</b> is <tt>nil</tt>.
 667	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 668	 *  <li>The object's <b>types</b> is <tt>[]</tt> (i.e. it has no types).
 669	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 670	 *  with a 'native' metaobject protocol).
 671	 * </ul>
 672	 * 
 673	 * Example: <code>object: { def x := 1; }</code>
 674	 * <p>
 675	 * Pseudo-implementation:
 676	 * <pre>object: code childOf: nil extends: false taggedAs: [] mirroredBy: defaultMirror</pre>
 677	 * 
 678	 * The closure used to initialize the object may contain formal parameters. The closure
 679	 * will always be invoked with <i>its own mandatory formal parameters</i>. E.g., a closure
 680	 * <code>{ |x| nil }</code> is invoked as <code>{ |x| nil }(x)</code>. The net effect of this
 681	 * mechanic is that if <tt>x</tt> is a lexically visible variable at the object-creation
 682	 * site, the value of the variable will be copied into a copy with the same name which
 683	 * resides in the newly created object. This mechanic is primarily useful for copying surrounding
 684	 * variables within the object, e.g. for isolates which lose access to their surrounding scope.
 685	 * <p>
 686	 * Also, if the closure has optional parameters, they will always be triggered.
 687	 * The expressions to initialize the formal parameters are <i>evaluated</i>
 688	 * in the context of the closure's lexical scope but are <i>added</i> to the newly created object.
 689	 * 
 690	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent
 691	 * @return a new AmbientTalk object with the properties defined above.
 692	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 693	 */
 694	public ATObject base_object_(ATClosure code) throws InterpreterException {
 695		return base_object_childOf_extends_taggedAs_mirroredBy_(
 696				code,
 697				OBJNil._INSTANCE_,
 698				NATBoolean._FALSE_ /* SHARES-A link */,
 699				NATTable.EMPTY,
 700				base_defaultMirror());
 701	}
 702	
 703	/**
 704	 * The <tt>extend:with:</tt> object creation primitive.
 705	 * This construct creates a new AmbientTalk object where:
 706	 * <ul>
 707	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 708	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 709	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 710	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 711	 *  <li>The object's <b>types</b> is <tt>[]</tt> (i.e. it has no types).
 712	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 713	 *  with a 'native' metaobject protocol).
 714	 * </ul>
 715	 * 
 716	 * Example: <code>extend: parent with: { def x := 1; }</code>
 717	 * <p>
 718	 * Pseudo-implementation:
 719	 * <pre>object: code childOf: parent extends: true taggedAs: [] mirroredBy: defaultMirror</pre>
 720	 * 
 721	 * @param parent the dynamic parent object of the newly created object.
 722	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent
 723	 * @return a new AmbientTalk object with the properties defined above.
 724	 * @see #base_object_(ATClosure)
 725	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 726	 */
 727	public ATObject base_extend_with_(ATObject parent, ATClosure code) throws InterpreterException {
 728		return base_object_childOf_extends_taggedAs_mirroredBy_(
 729				code,
 730				parent,
 731				NATBoolean._TRUE_ /* IS-A link */,
 732				NATTable.EMPTY,
 733				base_defaultMirror());
 734	}
 735	
 736    /**
 737     * The <tt>extend:with:taggedAs:</tt> object creation primitive.
 738	 * This construct creates a new AmbientTalk object where:
 739	 * <ul>
 740	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 741	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 742	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 743	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 744	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 745	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 746	 *  with a 'native' metaobject protocol).
 747	 * </ul>
 748	 * 
 749	 * Example: <code>extend: parent with: { def x := 1; } taggedAs: [foo,bar]</code>
 750	 * <p>
 751	 * Pseudo-implementation:
 752	 * <pre>object: code childOf: parent extends: true taggedAs: types mirroredBy: defaultMirror</pre>
 753	 * 
 754	 * @param parent the dynamic parent object of the newly created object.
 755	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 756	 * @param types a table of types with which to type the newly created object.
 757	 * @return a new AmbientTalk object with the properties defined above.
 758	 * @see #base_object_(ATClosure)
 759	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 760	 */
 761	public ATObject base_extend_with_taggedAs_(ATObject parent, ATClosure code, ATTable types) throws InterpreterException {
 762		return base_object_childOf_extends_taggedAs_mirroredBy_(
 763				code,
 764				parent,
 765				NATBoolean._TRUE_ /* IS-A link */,
 766				types,
 767				base_defaultMirror());
 768	}
 769	
 770    /**
 771     * The <tt>extend:with:mirroredBy:</tt> object creation primitive.
 772	 * This construct creates a new AmbientTalk object where:
 773	 * <ul>
 774	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 775	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 776	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 777	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 778	 *  <li>The object's <b>types</b> are set to <tt>[]</tt> (i.e. the object has no types).
 779	 *  <li>The object's <b>mirror</b> is the given mirror. This means that this object is a <i>mirage</i>
 780	 *  whose metaobject protocol is entirely dictated by the given mirror.
 781	 * </ul>
 782	 * 
 783	 * Example: <code>extend: parent with: { def x := 1; } mirroredBy: (mirror: {...})</code>
 784	 * <p>
 785	 * Pseudo-implementation:
 786	 * <pre>object: code childOf: parent extends: true taggedAs: [] mirroredBy: mirror</pre>
 787	 * 
 788	 * @param parent the dynamic parent object of the newly created object.
 789	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 790	 * @param mirror the mirror of the newly created mirage object.
 791	 * @return a new AmbientTalk object with the properties defined above.
 792	 * @see #base_object_(ATClosure)
 793	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 794	 */
 795	public ATObject base_extend_with_mirroredBy_(ATObject parent, ATClosure code, ATObject mirror) throws InterpreterException {
 796		return base_object_childOf_extends_taggedAs_mirroredBy_(
 797				code,
 798				parent,
 799				NATBoolean._TRUE_ /* IS-A link */,
 800				NATTable.EMPTY,
 801				mirror);
 802	}
 803	
 804    /**
 805     * The <tt>extend:with:taggedAs:mirroredBy:</tt> object creation primitive.
 806	 * This construct creates a new AmbientTalk object where:
 807	 * <ul>
 808	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 809	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 810	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 811	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
 812	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 813	 *  <li>The object's <b>mirror</b> is the given argument mirror. This means that the newly
 814	 *  created object is a <i>mirage</i> whose metaobject protocol is dictated by the given mirror.
 815	 * </ul>
 816	 * 
 817	 * Example: <code>extend: parent with: { def x := 1; } taggedAs: [foo,bar] mirroredBy: mirror</code>
 818	 * <p>
 819	 * Pseudo-implementation:
 820	 * <pre>object: code childOf: parent extends: true taggedAs: types mirroredBy: mirror</pre>
 821	 * 
 822	 * @param parent the dynamic parent object of the newly created object.
 823	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 824	 * @param types a table of types with which to type the newly created object.
 825	 * @param the mirror object of the newly created mirage object.
 826	 * @return a new AmbientTalk object with the properties defined above.
 827	 * @see #base_object_(ATClosure)
 828	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 829	 */
 830	public ATObject base_extend_with_taggedAs_mirroredBy_(ATObject parent, ATClosure code, ATTable types, ATObject mirror) throws InterpreterException {
 831		return base_object_childOf_extends_taggedAs_mirroredBy_(
 832				code,
 833				parent,
 834				NATBoolean._TRUE_ /* IS-A link */,
 835				types,
 836				mirror);
 837	}
 838	
 839	/**
 840	 * The <tt>share:with:</tt> object creation primitive.
 841	 * This construct creates a new AmbientTalk object where:
 842	 * <ul>
 843	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 844	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 845	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 846	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 847	 *  <li>The object's <b>types</b> is <tt>[]</tt> (i.e. it has no types).
 848	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 849	 *  with a 'native' metaobject protocol).
 850	 * </ul>
 851	 * 
 852	 * Example: <code>share: parent with: { def x := 1; }</code>
 853	 * <p>
 854	 * Pseudo-implementation:
 855	 * <pre>object: code childOf: parent extends: false taggedAs: [] mirroredBy: defaultMirror</pre>
 856	 * 
 857	 * @param parent the dynamic parent object of the newly created object.
 858	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent
 859	 * @return a new AmbientTalk object with the properties defined above.
 860	 * @see #base_object_(ATClosure)
 861	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 862	 */
 863	public ATObject base_share_with_(ATObject parent, ATClosure code) throws InterpreterException {
 864		return base_object_childOf_extends_taggedAs_mirroredBy_(
 865				code,
 866				parent,
 867				NATBoolean._FALSE_ /* SHARES-A link */,
 868				NATTable.EMPTY,
 869				base_defaultMirror());
 870	}
 871
 872    /**
 873     * The <tt>share:with:taggedAs:</tt> object creation primitive.
 874	 * This construct creates a new AmbientTalk object where:
 875	 * <ul>
 876	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 877	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 878	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 879	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 880	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 881	 *  <li>The object's <b>mirror</b> is the <tt>defaultMirror</tt> on objects (i.e. it is an object
 882	 *  with a 'native' metaobject protocol).
 883	 * </ul>
 884	 * 
 885	 * Example: <code>share: parent with: { def x := 1; } taggedAs: [foo,bar]</code>
 886	 * <p>
 887	 * Pseudo-implementation:
 888	 * <pre>object: code childOf: parent extends: false taggedAs: types mirroredBy: defaultMirror</pre>
 889	 * 
 890	 * @param parent the dynamic parent object of the newly created object.
 891	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 892	 * @param types a table of types with which to type the newly created object.
 893	 * @return a new AmbientTalk object with the properties defined above.
 894	 * @see #base_object_(ATClosure)
 895	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 896	 */
 897	public ATObject base_share_with_taggedAs_(ATObject parent, ATClosure code, ATTable types) throws InterpreterException {
 898		return base_object_childOf_extends_taggedAs_mirroredBy_(
 899				code,
 900				parent,
 901				NATBoolean._FALSE_ /* SHARES-A link */,
 902				types,
 903				base_defaultMirror());
 904	}
 905	
 906    /**
 907     * The <tt>share:with:mirroredBy:</tt> object creation primitive.
 908	 * This construct creates a new AmbientTalk object where:
 909	 * <ul>
 910	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 911	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 912	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 913	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 914	 *  <li>The object's <b>types</b> are set to <tt>[]</tt> (i.e. the object has no types).
 915	 *  <li>The object's <b>mirror</b> is the given mirror. This means that this object is a <i>mirage</i>
 916	 *  whose metaobject protocol is entirely dictated by the given mirror.
 917	 * </ul>
 918	 * 
 919	 * Example: <code>share: parent with: { def x := 1; } mirroredBy: (mirror: {...})</code>
 920	 * <p>
 921	 * Pseudo-implementation:
 922	 * <pre>object: code childOf: parent extends: false taggedAs: [] mirroredBy: mirror</pre>
 923	 * 
 924	 * @param parent the dynamic parent object of the newly created object.
 925	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 926	 * @param mirror the mirror of the newly created mirage object.
 927	 * @return a new AmbientTalk object with the properties defined above.
 928	 * @see #base_object_(ATClosure)
 929	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 930	 */
 931	public ATObject base_share_with_mirroredBy_(ATObject parent, ATClosure code, ATObject mirror) throws InterpreterException {
 932		return base_object_childOf_extends_taggedAs_mirroredBy_(
 933				code,
 934				parent,
 935				NATBoolean._FALSE_ /* SHARES-A link */,
 936				NATTable.EMPTY,
 937				mirror);
 938	}
 939	
 940    /**
 941     * The <tt>share:with:taggedAs:mirroredBy:</tt> object creation primitive.
 942	 * This construct creates a new AmbientTalk object where:
 943	 * <ul>
 944	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 945	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 946	 *  <li>The object's <b>dynamic parent</b> is the argument object.
 947	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 948	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 949	 *  <li>The object's <b>mirror</b> is the given argument mirror. This means that the newly
 950	 *  created object is a <i>mirage</i> whose metaobject protocol is dictated by the given mirror.
 951	 * </ul>
 952	 * 
 953	 * Example: <code>share: parent with: { def x := 1; } taggedAs: [foo,bar] mirroredBy: mirror</code>
 954	 * <p>
 955	 * Pseudo-implementation:
 956	 * <pre>object: code childOf: parent extends: false taggedAs: types mirroredBy: mirror</pre>
 957	 * 
 958	 * @param parent the dynamic parent object of the newly created object.
 959	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 960	 * @param types a table of types with which to type the newly created object.
 961	 * @param mirror the mirror object of the newly created mirage object.
 962	 * @return a new AmbientTalk object with the properties defined above.
 963	 * @see #base_object_(ATClosure)
 964	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 965	 */
 966	public ATObject base_share_with_taggedAs_mirroredBy_(ATObject parent, ATClosure code, ATTable types, ATObject mirror) throws InterpreterException {
 967		return base_object_childOf_extends_taggedAs_mirroredBy_(
 968				code,
 969				parent,
 970				NATBoolean._FALSE_ /* SHARES-A link */,
 971				types,
 972				mirror);
 973	}
 974	
 975    /**
 976     * The <tt>object:taggedAs:</tt> object creation primitive.
 977	 * This construct creates a new AmbientTalk object where:
 978	 * <ul>
 979	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
 980	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
 981	 *  <li>The object's <b>dynamic parent</b> is <tt>nil</tt>.
 982	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
 983	 *  <li>The object's <b>types</b> are initialized to the argument types table.
 984	 *  <li>The object's <b>mirror</b> is <tt>defaultMirror</tt> (i.e. the object has the
 985	 *  default metaobject protocol).
 986	 * </ul>
 987	 * 
 988	 * Example: <code>object: { def x := 1; } taggedAs: [foo,bar]</code>
 989	 * <p>
 990	 * Pseudo-implementation:
 991	 * <pre>object: code childOf: nil extends: false taggedAs: types mirroredBy: defaultMirror</pre>
 992	 * 
 993	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
 994	 * @param types a table of type tags with which to type the newly created object.
 995	 * @return a new AmbientTalk object with the properties defined above.
 996	 * @see #base_object_(ATClosure)
 997	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
 998	 */
 999	public ATObject base_object_taggedAs_(ATClosure code, ATTable types) throws InterpreterException {
1000		return base_object_childOf_extends_taggedAs_mirroredBy_(
1001				code,
1002				OBJNil._INSTANCE_,
1003				NATBoolean._FALSE_ /* SHARES-A link */,
1004				types,
1005				base_defaultMirror());
1006	}
1007	
1008    /**
1009     * The <tt>isolate:</tt> object creation primitive.
1010	 * This construct creates a new AmbientTalk object where:
1011	 * <ul>
1012	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
1013	 *  <li>The object's <b>lexical parent</b> is initialized to the lexical scope of the argument closure,
1014	 *  but because it is typed as an isolate, the parent link is replaced by a link to the lexical <tt>root</tt>.
1015	 *  <li>The object's <b>dynamic parent</b> is <tt>nil</tt>.
1016	 *  <li>The object's <b>parent type</b> is <b>SHARES-A</b> (i.e. it is not an extension of its parent).
1017	 *  <li>The object's <b>types</b> are initialized to <tt>[/.at.types.Isolate]</tt>, i.e.
1018	 *  the object is typed as an isolate.
1019	 *  <li>The object's <b>mirror</b> is <tt>defaultMirror</tt> (i.e. the object has the
1020	 *  default metaobject protocol).
1021	 * </ul>
1022	 * 
1023	 * Example: <code>isolate: { def x := 1; }</code>
1024	 * <p>
1025	 * Pseudo-implementation:
1026	 * <pre>object: code childOf: nil extends: false taggedAs: [/.at.types.Isolate] mirroredBy: defaultMirror</pre>
1027	 * 
1028	 * An isolate is an object without a proper lexical parent. It is as if the isolate is always
1029	 * defined at top-level. However, lexically visible variables can be retained by copying them into the isolate
1030	 * by means of formal parameters to the argument closure. Isolate objects are passed by-copy during
1031	 * inter-actor parameter and result passing.
1032	 * 
1033	 * @param code a closure containing both the code with which to initialize the object and the new object's lexical parent.
1034	 * @return a new AmbientTalk object with the properties defined above.
1035	 * @see #base_object_(ATClosure)
1036	 * @see #base_object_childOf_extends_taggedAs_mirroredBy_(ATClosure, ATObject, ATBoolean, ATTable, ATObject)
1037	 */
1038	public ATObject base_isolate_(ATClosure code) throws InterpreterException {
1039		return base_object_taggedAs_(code, NATTable.of(NativeTypeTags._ISOLATE_));
1040	}
1041	
1042    /**
1043     * The <tt>mirror:</tt> object creation primitive.
1044	 * This construct creates a new AmbientTalk object where:
1045	 * <ul>
1046	 *  <li>The object is initialized with the <i>code</i> of the argument closure.
1047	 *  <li>The object's <b>lexical parent</b> is the lexical scope of the argument closure. 
1048	 *  <li>The object's <b>dynamic parent</b> is <tt>defaultMirror</tt>.
1049	 *  <li>The object's <b>parent type</b> is <b>IS-A</b> (i.e. it is an extension of its parent).
1050	 *  <li>The object's <b>types</b> are initialized to <tt>[]</tt>.
1051	 *  <li>The object's <b>mirror</b> is <tt>defaultMirror</tt> (i.e. the object has the
1052	 *  default metaobject protocol).
1053	 * </ul>
1054	 * 
1055	 * Example: <code>mirror: { def x := 1; }</code>
1056	 * <p>
1057	 * Pseudo-implementation:
1058	 * <pre>object: code childOf: defaultMirror extends: true taggedAs: [] mirroredBy: defaultMirror</pre>
1059	 * 
1060	 * This construct is mere syntactic sugar for creating an extension of the default mirror root.
1061	 * It follows that AmbientTalk mirrors are plain AmbientTalk objects. They simply need to implement
1062	 * the entire metaobject protocol, and the easiest means to achieve this is by extending the default mirror.
1063	 * Also keep in mind that the mirror is an extension object. This is important because the default
1064	 * mirror has <i>state</i>, being the <tt>base</tt> field that points to the base-level object
1065	 * being mirrorred. Hence, always make sure that, if overriding <tt>init</tt>, the par

Large files files are truncated, but you can click here to view the full file