Core constructs

Data

 

This is straightforward, it provides a way to structure data. But what is data? Are functions data? Can structured data contain functions? What about other more complex constructs?

 

The short answer is: yes, functions like any other piece of code is also data. Therefore, it can also be stored in structured data ...but this is not always the best place to put them.

 

Data have a flexible type system and support multiple inheritance.

 

 

Functions

 

In Arplan, functions are like mathematical functions. That is, they are black boxes that compute some output based on the input arguments. Unlike in usual programming languages, functions in Arplan are "self-contained", they have strong restrictions:

  • they cannot read nor modify extern stateful variables
  • they cannot modify input related data
  • they cannot interract with the environment
  • they are stateless

The environment is never altered and there are no side effects. These restrictions have 2 great benefits:

  • functions are 100% deterministic: if you give the same input, you will get the same output, whatever the state of the system is.
  • Calling a function cannot alter the state of the system.

This is good to separate computation from maintaining the system state. If a function is correct on its own, it will be correct in the whole system whatever you do. The converse is also true, calling a function will never corrupt the state of your system.

 

This makes it easier to combine them, to make functions out of functions and to reason about them. Of course, inside functions, you can use temporary state and complex models to obtain the desired output.

 

 

Agents

 

They are stateful entities that can provide services and react to events. A service can alter the agent's state, can cause further service calls and raised events. Ultimatively, the agent may return some result.

 

There are several differences with objects:

  • You cannot ask an agent to get a reference to another agent, you can only get data.
  • There is no inheritance ...but ***
  • Services/events are synchronized
  • All agents are running independently (in their own thread)