Code et datas

         In traditional languages, code and datas are separated. However, in complex applications (such as the animation of autonomous actors), it is no longer possible to exercise comprehensive control program running linearly. It is easier to let these actors to decide for themselves the details of their behavior, control is limited to providing general guidance.
         For this we consider that each actor is actually a program accessing the database and local memories. Everything happens as if multiple programs were conducted in parallel and can communicate among themselves and with the "supervisor" (in this case the animattor becomes a director).

Implementation in anyflo

         Anyflo language is an interpreter written in C, but does not have the limitations of compiled languages efining fixed structures: because everything is dynamically defined: datas, types and even code that can be dynamically generated during execution.


Definition of a local functions

         Command local(0)vol(id°="f" adds, in volume id, a local function copy of function f().
         A convenient way to proceed is to write a function, eg foo, and do: local (0) vol (id)= "foo".
         Text, and compiled code, of a copy of the function foo become properties of volume id.
         The same function can be loaded into different objects and run no synchronously.

Access to a local function

         local(id_loc)obj(id_obj) references local fonction id_loc of object id_obj.
         1) $(local(2)vol(1)): prints the text of 2nd local function of volume 1.
         2) local("foo")vol(1)="b": replaces the local function foo of volume 1 by the function b.
         3) edit local vol(1): edits the local functions names of volume 1.
         4) $(local(2)vol(1)): prints the text of local function 2 of volume 1.
         5) w=local("foo")vol(1): puts in w the local function text foo of volume 1.

Execution of the local functions

Execution by default

         If yes local is active, the first local function of a volume is executed before displaying it

Intern call

         A function of a local object can call another of the same object by simply invoking his name (and it can not be any ambiguity with other functions with the same name located outside the object).

Extern call

         It is possible to run any local function of any object, either from another object, or from the main program by:
         exec local(n)vol(id); runs the local fonction number n of volume id without parameters.
         exec local("foo")vol(id); runs the local fonction foo of volume id without parameters.
         exec local(n)vol(id)var(x)var(y)var(z); runs the local fonction number n of volume id by passing the parameters x, y, z.


External variables

         Like any function, a local function can have access to external variables that are known everywhere.
         extern name_of_variable;

Static variables

         Like any function, a local function can have static variables which are permanent but known only within this function.
         static x,y,z; defines static varaibles x, y, z.
         static x=(1,2,3); defines static variable x initialized to (1,2,3).

Global variables

         Global variables, ie a specific object and known by all local functions (and unknown to the outside), can be defined by the statement:
global g;
global g=1;: initializing it to 1.


         demo1_local() runs the function demo1_local().
         This function encapsulates the same program in multiple cubes that behave différamment.
         It also defines an adaptive view.