Duality of objects and values allows looking at a modeling system as a set of collaborating objects, and the same time operate object states in some data approach like relation model and SQL.
An object can have collaborators and state. Collaborators are objects, object state is a value. In similar way, in message implementations local names (variables) can be either objects or values.
Messages return strictly values, and message parameters are strictly objects.
Conceptually, reading and writing some value (in general sense) differ in their nature: writing requires validation, but reading does not (I generalized the requirement of writing validation: since some value can be written to a variable, this value may be wrong). Both (reading and writing) may also require such features like authorization, filtering, confidentiality etc., but validation is a property of writing.
The idea is to apply CQRS for manipulating objects. Messages are the way to change object state (and provide validation), while reading object state is a separated Paml feature. Variables can be either of object type or value type. There is symmetrical mechanism for this duality: a variable can be declared as an object to send messages, or as a value to read its state and look at the object as data (with possible relations in SQL style).
Keyword dataOf takes an object and switches its "view" to state data, which is a value. With this value reading operations are possible. Keyword objectOf takes a value and switches its "view" to corresponding object for sending messages. The variables passed into the keywords are join point: transformations will define how and what is used exactly in expressions.
The keywords dataOf and objectOf are not actually like functions, they are just syntax to switch how an object is considered: as an object for sending messages or as data for reading its state values.
Local variables are declared with val and obj keyword that declare some value or object respectively. Then variables are manipulated with dataOf and objectOf operations.
There is a topic about assigning properties by some values in GPL like C#. An assign operation is naturally low-level operation and very abstract. In Paml, objects do not have properties or fields at all. So changing even a single state item requires a message. This seems that even simple assignment operations will have a meaning name. For example, if there is object Circle and it has Radius state item, in order to change only the radius a message is required, and seems Resize name is well for it.
Write a comment