PageRenderTime 45ms CodeModel.GetById 11ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 1ms

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

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

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