PageRenderTime 51ms CodeModel.GetById 20ms app.highlight 20ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/reactive-pattern-matching/src/edu/vub/at/objects/natives/OBJLexicalRoot.java

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

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