To understand how PLAN programs evaluate, it is imperative to understand their evaluation environment: the PLANnet, depicted in Figure 1. A PLANnet consists of hosts, which form the end-points of the environment, and routers, which form the cloud. Collectively, hosts and routers are referred to as nodes. Hosts are essentially distinguished from routers in that they may serve host applications which form part of a PLAN application. All nodes must be capable of evaluating PLAN programs.
While in an actual PLANnet each node would be a separate machine, in the
PLAN 2.2 implementation, nodes are identified by pairs so that two distinct nodes may actually exist on the same
machine, differentiated by their ports.
This is made possible by the fact that the
implementation currently uses UDP/IP as its network interface. This is
ironic in that one of PLAN's goals is to replace IP as the network
layer in an internetwork; however, making use of IP at this juncture
simplifies the implementation, and facilitates experimentation. Plans are
underway to removed the IP dependency from the PLAN implementation.
Figure 1: PLANnet: the PLAN evaluation environment
A PLAN packet begins its life at a host, specifically within a host application. The application constructs a PLAN packet and injects it into the active network by handing it to the PLAN interpreter on its host. This is done by creating a PLAN port between the application and the interpreter, called the injection port (or implicit port). This port allows the interpreter to provide output to the application, and allows the application to submit new PLAN packets.
The local interpreter then proceeds to route the packet to its evalDest,
making use of the provided routFun to determine the next hop. At
each hop on the way to the evalDest, resource bound is subtracted from the
packet; if at any time the resource bound is exhausted, the packet is
terminated. When a PLAN packet reaches its evalDest, its program is
evaluated. First, the code is parsed top-down to register the top-level
bindings. All function bindings respect static scoping; that is, the
set of bindings available to a function when it is evaluated are those that
were available when it was defined. Evaluation then begins with the
function call defined by the invocation. Any value that
would have been returned by the function is discarded.
Any exceptions (see Section 4) which are not explicitly handled by the PLAN program cause the execution of the program to be terminated. In other words, there is no error reporting mechanism, although programs can certainly implement their own (assuming they have enough remaining resource bound to create the appropriate packets).