Actors

BOOL Actor objects link to and invoke Action objects. An Actor Object is essentially the “instance” of an Action.

Description

A BOOL Actor links to its Action via a shared name. Currently the linkage can be static or dynamic (the latter requiring some form of run-time binding of names).

Syntax

@action-name  parameter(s)

The Action must be known at compile-time, because the arity must be known (and BOOL needs to know it can link to the Action). Actions can take zero or more parameters, so Actors have zero or more parameters to match.

Actor parameters are objects following the Actor object and having the same dot level. Because the arity is known, the compiler consumes however many following objects are required by the Actor.

Examples:

@hypot 3 4
@if zero:ix @print Document
@incr x

Implementation

The basic algorithm for an Actor is:

Actor::HandleMessage (actor, message):
    action = GetObject(actor.action)
    action.invoke(actor.cplist)
    result = PStack.pop()
    CallFrame.set_value(actor.result, result)
    if message != 'X':
        SendMessage(actor.result, message)

The TEMP object associated with the TOR object acts as the code address for the Action’s result object. The last lines above pop that result from the stack and move it to the TEMP object and current Call Frame.

Python binding

(TEMP, T_any, dx): @temp
(TOR, name, clause-parameter-list, @temp)

The clause-parameter-list consists of clause objects, which each have the format:

(clause-name, parameter(s))

The parameter(s) are zero or more parameters as specified by the clause definition of the Action.

Advertisements

Speak to me!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: