New Syntax and Semantics for Object/Data Access Operators

"Object instance" expression is introduced instead of objectOf operator.

An object variable can be accessed via both operators, object access operator "->" (to send messages) and data access operator "." (to read state data). To read object state, no explicit dataOf operator required for an object variable, but the operator is implicitly assumed there.

Operator dataOf can be explicitly applied to an object variable to get its state data.

A value variable can be accessed via only data access operator "." to read and write data.

Operator objectOf is replaced by "object instance" expression, which is also a join point. The syntax of the expression looks like a call of constructor in GPL like C#, and the semantic is similar to getting an instance. But in Paml this expression just means that an object is obtained in some way from arguments of the expression. Transformations will define how exactly an object is obtained (create new instance, resolving identifier to reference etc).

An object variable can be declared (with object type) or declared and initialized (with "object instance" expression). The object type can be inferred from "object instance" expression.

object Alonzo . Drawing . Circle
data Radius : double;
message Resize ( radius : double )
this.Radius = radius;
message Resize ( delta : double )
this.Radius += delta;
subject Alonzo . Drawing . Painter
data Circles : Alonzo . Drawing . Circle [] ;
message Render
An object variable declaration.
obj circle : Alonzo . Drawing . Circle ;
An object variable declaration and initialization. "object instance" expression is a join point.
obj circle = Alonzo . Drawing . Circle ( ) ;
A value variable declaration.
val radius : double;
A value variable declaration and initialization.
val radius = 120.0;
circle->Resize ( radius: 60 ); Sending a message to the object
radius = circle.Radius; Accessing the object state, reading its data.
The type of "data" variable is Alonzo.Drawing.Circle value.
val data = dataOf ( circle ) ;
The such data is read-only? Navigation through relations?
radius = data.Radius;
Transformations define how an object in "object instance" expression is obtained from the expression arguments.
circle = Alonzo . Drawing . Circle ( data ) ; Argument is the circle value
circle = Alonzo . Drawing . Circle ( radius ) ; Argument is a radius value
circle -> Resize ( delta : 600 );

Write a comment

Comments: 0

Pallada project, Copyright © 2015 - 2021.

For any mentions and citations of the site materials, a link to the Pallada project site is obligatory.