actor: { code }
== actor: { code } mirroredBy:
The semantics of actor creation is as follows:
- Mandatory parameters to the block of initialization code are treated as lexically visible
variables that have to remain available in the new actor behaviour.
Apply the NativeClosure, which either gives rise to executing a native piece of
code supplied by an anonymous subclass, or executes the wrapped NativeMethod.
A closure method application acts exactly like a regular direct method application, except that
the given lexical scope is disregarded and replaced by the lexical scope encapsulated by the
closure method.
The do:if: primitive, which in Ruby terminology is a 'statement modifier'
usage:
do: { body } if: condition
pseudo-implementation:
condition.ifTrue: { body }
The do:unless: primitive, which in Ruby terminology is a 'statement modifier'
usage:
do: { body } unless: condition
pseudo-implementation:
condition.ifFalse: { body }
{ |quit| ... quit(val) ... }.escape()
The escape control construct passes to its receiver block a function which
when invoked, immediately transfers control back to the caller of escape,
returning the value passed to quit.
export: object as: topic
=> object becomes discoverable by objects in other actors via topic
returns a publication object that can be used to cancel the export
Clears the content of the mailbox (i.e. mailbox becomes empty)
and return all current messages in a fresh table, which is no longer
causally connected to this mailbox.
The foreach:in: primitive, which calls back on the table using each:
usage:
foreach: { |v| body } in: [ table ]
pseudo-implementation:
[ table ].each: { |v| body }
The if:then:else primitive, which calls back on the boolean using ifTrue:ifFalse:
usage:
if: booleanCondition then: { consequent } else: { alternative }
pseudo-implementation:
booleanCondition.ifTrue: { consequent } ifFalse: { alternative }
A Java interface type used as a stripe can only be a substripe of another
Java interface type used as a stripe, and only if this type is assignable
to the other type.
def online() { make the interpreter go online; return nil }
After invoking this method, publications and subscriptions can interact
with those of remote VMs.
retract: farReference
=> retract all currently unsent messages from the far reference's outbox
This has the side effect that the returned messages will *not* be sent automatically anymore,
the programmer is responsible to resend all messages that still need to be sent by hand.
NBR(start).to: NBR(stop) do: { |i| code } => for i = start to stop do code.eval(i) ; nil
Also works if stop > start, in which case it becomes a downTo.
NBR(start).to: NBR(stop) step: NBR(inc) do: { |i| code } =>
for i = start; i < stop; i++ do code.eval(i) ; nil
Also works if stop > start, in which case it becomes a downTo.
try: { tryBlock } usingHandlers: [ handler1, handler2, ... ]
Applies the given closure (to []) and handles exceptions using the given exception handlers.
when: farReference disconnected: { code }
=> when the remote reference is broken due to network disconnections, trigger the code
returns a subscription object that can be used to cancel the listener
when: topic discovered: { code }
=> when an object is exported by another actor under topic, trigger the code
returns a subscription object that can be used to cancel the handler
Once the code block has run once, it will not be triggered again.
when: farReference reconnected: { code }
=> when the remote reference is reinstated after a network disconnection, trigger the code
returns a subscription object that can be used to cancel the listener
whenever: topic discovered: { code }
=> when an object is exported by another actor under topic, trigger the code
returns a subscription object that can be used to cancel the handler
The code block can be fired multiple times.
Allows AmbientTalk programmers to write
{ booleanCondition }.whileTrue: { body }
which will execute body as long as the boolean condition evaluates to true.
The while:do: primitive, which calls back on the closure using whileTrue:
usage:
while: { condition } do: { body }
pseudo-implementation:
{ condition }.whileTrue: { body }
Performs the main boot sequence of the AmbientTalk VM and environment:
1) Create a virtual machine using the correct object path and actor initialisation
2) Create a new actor which knows how to interface with IAT (it knows execute: and the system object)
3) Create a barrier which allows synchronizing between an actor and the REPL
4) Ensure the barrier is informed of results by registering it as an observer
5) Send the main code specified by the user to be executed by the actor.