Collection Operations

Collections in Paml actually define a data model.

Duality of variables in Paml is the outcome from two different modeling approaches, data model and object model, which implicitly exist in object-oriented programs.

The syntax of collection operations is based on SQL and LINQ syntaxes.

One of LINQ features is that LINQ actually applies a data model for operating on sequences of items. In modern programming languages, only raw iterative data structures are defined such as arrays, lists, dictionaries, queues etc.

Paml takes the LINQ concepts for explicit data model in a language and uses a collection as an abstraction for any sequences of items. A collection can be then transformed into particular data structure or container, such as a list or database table.

Items of a collection are actually values, though collection can be declared with items as objects. In this case object instance expression should be used in projection and object access operator to access items as objects for sending messages to them.

For collection, operations are defined such as filtering, sorting, projecting, grouping etc. Actually they are query elements. Such collection operations like adding items, removing or finding, they look like aspects or symbolic operators, and as so should be implemented via transformation, and models just define syntax for them.

object Circle
{
data X, Y : double;
data Radius : double;
message Draw
{
TODO:
}
}
subject Painter
{
data Circles : Circle[];
message Render
{
this.Circles (circle) "circle" is a name for iterating item
orderBy ( circle.X, circle.Y )
select {
circle.X } (x) "x" is a name for iterating item
where {
x > 200 }
forEach {
print(x) }; "print" is a symbolic operator in N-arity format
this.Circles (circle)
select {
Сircle (circle) } "object instance" expression here
forEach {
circle->Draw() }; "circle" is an object now, message sending is possible.
}
}

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.