Productions and Resources

Productions and resources are a bridge between abstraction level of Paml models and actual output code in C#, which will be compiled/debugged into binaries like DLL.

Paml productions and resources syntax elements are just to define formal syntax and semantics of the language. The idea is that no need to write such Paml code manually in real projects in daily working, IDE must provide a rich functionality to make easy developing and writing output code. But formally, such Paml code can be written, parsed and interpreted correctly by Paml translator.

Objects, subjects, abstractions, and projections are a term level; they are abstractions that's models. On the model level just logically suppose that models (objects, subjects, etc.) have associated projections. A projection has an instantiating policy, for simplicity suppose that all projection instantiating policies are static and no instances need to be created/disposed.

Injection varInit is removed from Paml, now four injections are defined: beforeBlock, beforeBody, afterBody, and afterBlock. Possibly new injection will be added like body.

A production is a set of resource definitions. Productions are Paml syntax elements, but their "implementation" is written in output language such as C#.

Productions are static for now, like projections approach. That's both projections and productions are static elements and do not required any factories to create their instances.

Resources (and resource definitions) can be of two fundamental kinds: memory and algorithm. Specific kinds of resources can be defined, like locks, transactions, cycles(!) etc., but they all are just particular kind of the two. Models are just abstractions that define terms from a domain. Productions with resources are used to assign real code and memory to the models.

A resource definition consists of resource procedures. For memory resource, procedures are init, release, and recover. For algorithm resource, the only procedure is execute. Resource definitions can share some state in their production, because resource implementation can be complex enough.

Resources are injected into resource slots. Resource slots are items of metadata of Paml code elements such as variables or association properties. Metadata consist of injection points and resource slots. Depending on the kind of code element there can be a structure of injection points and resource slots.

Resource slots have a scope of two kinds: routine and object. A resource slot can be set to release the assigned resource (if any) when the slot is going outside of its scope (the control flow gets outside a routine or an object is disposed).

Assigning resources from productions into resource slots are matched via resource selectors. Unlike injection selectors, which are specified for injections, resource selectors are specified for resource slots.

A resource slot can pass some arguments to resource procedures. This is a feature to avoid global scope, all pieces of code, in Paml or output language, are assigned as "functions", that's they can use only their "parameters". This can (and probably must) be supported by IDE to display a scope for each element because such scope is expected to be very short, just a few names.

Suppose we are modeling an operating system named "Polo" in Alonzo Corp.
enumeration
{
Active, Inactive
}
object
{
data : string;
data : Alonzo.Polo.ProcessStatus;
Collaborator can be an "one" side from an association?
collaborator ; The type of Kernel collaborator is inferred as Alonzo.Polo.Kernel
message
{
Kind Routine
Id
Name
Tags
this.Kernel ->StopProcess ( : this );
}
message
{
Kind Routine
Id
Name
Tags
this.Kernel ->StartProcess ( : this.Name );
}
message ( val priority : Alonzo.Polo.ThreadPriority )
{
Kind Routine
Id
Name
Tags
obj : Alonzo.Polo.Thread;
thread->Start ( );
this.Threads thread;
}
message ( obj thread )
{
Kind Routine
Id
Name
Tags
thread->Stop ();
this.Threads thread;
}
}
enumeration
{
Running, Waiting
}
enumeration
{
Normal, High, Low
}
object
{
data : string;
data : Alonzo.Polo.ThreadStatus;
data : Alonzo.Polo.ThreadPriority;
collaborator ;
collaborator ;
message ( val priority : Alonzo.Polo.ThreadPriority )
{
Kind Routine
Id
Name
Tags
this.Priority = priority;
}
message
{
Kind Routine
Id
Name
Tags
}
}
association
{
Alonzo.Polo.Thread. (1) - (*) Alonzo.Polo.Process.
}
object
{
message ( val name : string )
{
Kind Routine
Id
Name
Tags
obj ;
process->Start ();
this.Processes process;
}
message ( obj process ) The type of 'process' parameter is inferred as Alonzo.Polo.Process
{
Kind Routine
Id
Name
Tags
process->Stop ();
this.Processes process;
}
}
association
{
Alonzo.Polo.Process. (1) - (*) Alonzo.Polo.Kernel.
}
projection
{
afterBody Message: Name is Alonzo.Polo.Kernel.StartProcess ( obj process : Alonzo.Polo.Process )
{
Kind Routine
Id
Name
Tags
( process );
}
beforeBody Message: Name is Alonzo.Polo.Kernel.StopProcess ( obj process )
{
Kind Routine
Id
Name
Tags
( process );
}
}
production
{
memory ( string name, Alonzo.Polo.Kernel owner )
{
init Alonzo.Polo.Process process
{
process = new Alonzo.Polo.Process ();
process.Name = name;
process.Owner = owner;
}
release
{
process.Owner = null;
delete process;
}
recover
{
}
}
memory
{
init System.Collections.List<Alonzo.Polo.Thread> threads
{
threads = new System.Collections.List<Alonzo.Polo.Thread> ();
}
release
{
}
recover
{
}
}
}
production
{
memory ( Alonzo.Polo.ThreadPriority priority, Alonzo.Polo.Process owner )
{
init Alonzo.Polo.Thread thread
{
thread = new Alonzo.Polo.Thread ();
thread.Priority = priority;
thread.Owner = owner;
}
release
{
thread.Owner = null;
delete thread;
}
recover
{
}
}
}

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.