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

/interpreter/tags/at2-build190607/src/edu/vub/at/objects/natives/OBJLexicalRoot.java

http://ambienttalk.googlecode.com/
Java | 1490 lines | 338 code | 91 blank | 1061 comment | 8 complexity | 7cca990d5a3e718d406f2d0a45ec94ca MD5 | raw file

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

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

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