ASPL Programming ver 1.00
© 2024 Bassem W. Jamaleddine


2-1

   ASPL A SIMPLIFIED VIEW

The ASPL interpreter is a general purpose set-calcultor that has many features to do operations on datasets. It is an interactive application where the user interacts with his aggregated datasets at the ASPL prompt, and the application provides many operators to do sophisticated algebraic set operations and display their results in real time. The interpreter also provides a scripting language that is simple but powerful enough to supplement your system with analytical commands. In this chapter, we describe only those features of ASPL that are sufficient for interacting with ASPL.

In this chapter, we describe only those features of ASPL that are sufficient for writing reasonaly interesting scripts.

Comments may be added to a statement by typing two successive semicolons (;;) anywhere to the right and following it with the comment.



Figure: It is possible to use the semicolon (;) to seperate multiple statements that are typed on the same line.

■ ASPL Statements

Statements are typed one to a line. The components of a statement must be seperated by at least one blank. Comments may be added to a statement by typing two successive semicolons (;;) anywhere to the right and following it with the comment.
Any line starting with two successive semicolons (;;) is considered a comment and is ignored by the interpreter.

   this is pre 

aspl> a1 = ggdir /tmp/aa1
    (result is assigned to a1)

aspl> a2 = ggdir /tmp/aa2
    (result is assigned to a2)



   this is pre 


Figure:

It is possible to use the semicolon (;) to seperate multiple statements that are typed on the same line.

ASPL statements are of three kinds: set operations, aspl directives, and aspl commands.

set operations are expressions that starts with a set operator mnemonic. These set operations can also be assigned to identifiers (variables) by preceding them with an identifier name and a the assignment symbols(*). The set operations can also be a functions that return datasets objects. The set operations are carried out through symbolic or keyword operators. density ? sim f&

set operations are of five kinds: Set operators, called setops, these operators perform basic set operations on datasets, their results may be assigned to identifiers called set variables. setness equal Sequence alignment operators, called seqops, these operators align and display datasets. Similarity operators that calculate and display similarity between datasets. Their results may be assigned to identifiers called COS variables. Directive commands that allow the user to control the state of ASPL internal components. Miscellanous commands that include: UNIX like commands to allow the user to navigate through the system seemlessly, as ASPL is a containment application that uses the UNIX filesystem extensively to store its data. UNIX like commands to make ASPL easy to use and integrate with the UNIX shell where it is being started. Containment commands to control or to communicate with ASPL containers. The containment commands are used to ping, to add to, or to delete from ASPL containment grouping class.

The directives are commands from the user to the interpreter to either carry out some action during interpretation or to change the state of ASPL loading containers. Some of ASPL startup options flags can be reset by using their corresponding directives.



The ASPL interpreter is a powerful application because (a) it is build on top of the UNIX shell, and (b) it uses the powerful Perl interpreter virtual machine.

Some commands run through the shell interpreter, these are basic UNIX commands (that do not alter anything in your UNIX system) like the ls, cd, pipe for the pager, which, env, and the editor. These commands are made available to make it convenient to navigate through ASPL directories without leaving ASPL. ASPL commands are these issued from the user to the interpreter to display some information as such attributes gourpingclass egCwhoami.. v ans v d a1 v gad display dumpgad usage Such commands are the sorts of ~tmp and ~home that change directory to ASPL temporary directory and ASPL home directory respectively, ll and wls commands that list the files in the current directory and list the workspace repository respectively, etc. usage whichma

The user can type help at the ASPL prompt to get a list of the basic commands. The help utility can also display information by category. The first time you start your ASPL interpreter you will be prompted to enter a command. By default the ASPL interpreter start by loading the TRIVIAL workspace which is the basic workspace.

       Figure monitor-socket-state.png
full view

Image File

 -F- Fig. 2.1.1   [Figure Monitoring UNIX System Socket State]
ASPL (C) 2024 Bassem Jamaleddine


Multiple statements can be typed on a single line as long as they are seperated by a single semicolon (;). Figure: It is possible to use the semicolon (;) to seperate multiple statements that are typed on the same line. For example:



Mainbullet: -title The Answer Stack

 

■ Basic Set Operations and Shapes

ASPL functions are defined with the DEF FN. An ASPL function is just an alias to an ASPL expression.

To make things simple in discussion, we shall talk about the shape of a variable and define the different shaped variables content as follow:

The Gs(S) denotes the contents of dataset S whose shape is H_H_H, that is an object of hash-of-hash-of-hash

The Ga(S) denotes the contents of augmented-dataset S whose shape is H_H_AH, that is an object of hash-of-hash-of-array-of-hashes

The Gp(S) denotes the contents of parted-dataset S whose shape is H_H_H_H or H_H_H_AH

Hence it becomes apparent that a shaped variable H_H_AH can hold more information than another whose shape is H_H_H.

That is true when one see the tail of both shapes, one ending in '_AH' (as array of hashes) and the other ending in '_H' (as hash).

In general, an array of hashes is a bin of objects, while a hash is just an object. One can add more objects to a bin (and hence hold more information in

that bin), while this is not possible with a hash as the object attributes may overlap.

For example fU and f& and f\ have the following operations, respectively:

Setop Set-instruction Operation

--------------------- --------------------

fU a1 a2 UNION Gs(a1) Gs(a2)

f& a1 a2 INTERSECT Gs(a1) Gs(a2)

f\ a1 a2 DIFFERENCE Gs(a1) Gs(a2)

For example f& f*& c& fP cP have the following operations, respectively:

Setop Set-instruction Operation

--------------------- --------------------

a12i = f& a1 a2 Gs(a12) <- INTERSECT Gs(a1) Gs(a2)

A12i = f*& a1 a2 Ga(A12i) <- SHALLOWINTERSECT Gs(a1) Gs(a2)

A12c = c& a1 a2 Ga(A12c) <- CHECKSUMINTERSECT Gs(a1) Gs(a2)

A12p = fP a1 a2 Gp(A12p) <- PARTITION Gs(a1) Gs(a2)

A12pc = cP a1 a2 Gp(A12pc) <- PARTITIONCHECKSUM Gs(a1) Gs(a2)

a12i = f& a1 a2

resulting set has shape H_H_H

A12i = f*& a1 a2

resulting set has shape H_H_AH

A12c = c& a1 a2

resulting set has shape H_H_AH

A12uc = cU a1 a2

resulting set has shape H_H_AH

A12p = fP a1 a2

resulting set has shape H_H_H_H

A12pc = cP a1 a2

resulting set has shape H_H_H_AH

The ASPL command shape when followed by a variable will print the shape of the variable:

aspl> shape a12i

aspl> shape A12i

aspl> shape A12c

aspl> shape A12uc

aspl> shape A12p

aspl> shape A12pc

f& setop instructs ASPL to do the intersection operation of two set variables.

In the absence of the set variables, ASPL will look into the answer stack to do the operation.

Where did all the variables go? next, tattler

 

■ ASPL Symbol Tables

ASPL maintain

Let's repeat the previous operations, but this time you will enable the tattler:

aspl> tattler 1

The tattler will add a small bar showing where a dataset object is read from and where the result of the operation is stored.

ASPL set operators have. Chapter CCCCC is a reference to ASPL set operators, it is valuable guide that list each set operator

along the type of operands the operator expect. Let's look at the f& (Ref: ) where the operands expected are .. also at the bottom

of the box, there are ins: and ous:

The ins: is where the objects are fetched, and

the ous: is where the objects are stored.

ASPL read an identifier from a specific symbol table, depend of the operator

ASPL stores it identifiers in three symbol tables, depend on the shape of the resulting operation.

 

■ ASPL Variables

A variable is a container that you create. You can create a variable any time you need one, and there is no limit (other than available memory) to the number of variables you can create or to their size. You create a variable by putting a value into it. ASPL variables are all global variables. There is no variable declaration, and for the user all ASPL variables can be viewed as typeless variable. By default all variables reside in memory and are never stored in disk until they are committed and stored in their named workspace. While variables are stored in memory, they can also be committed and saved in a named worskspace.

ASPL has a flag to make all variable persiisted immediately to their workspace. When the variable persistence flag is turned on then the variables end up being stored on disk, and if two or more ASPL instances are started with the same named workspace then all variables are being shared globally by all ASPL instances. The workspace directory worspace should be available to all instances.



Since ASPL variables are typeless and the result of a set operation may return an object of different shape, then ASPL will determine the way to store this variable. The user does not need to declare any variable type, but has to pay attention to the type of operation. Just consider the two operations a12 = fU a1 a2 and simi12 = sim a1 a2, the first operation creates the variable a12 in the setop symbol table, while the second operation creates the variable simi12 in the COS symbol table.

You cannot delete variables, but you can assign the same variable as many time. You can clear all symbol tables with CLEAR. You can kill the session with CONTROL-C and restart again, if the workspace is saved you can delete it and recreate it.



 

● TyP1 Set Variables

When using the f& to determine .. these

 

● TyP2 Set Variables

When using the c& to determine .. these multiple files are elements that need to be binned..

This set operation determines the files with similar names that have the same content. The setop c& is to get the set intersection of the files checksum on a group of directories.

 

Example 2.1.1

The following example shows how ASPL variables get to exist once they are assigned

aspl> a1 = ggdir /tmp/aa1
    (result is assigned to a1)

aspl> a2 = ggdir /tmp/aa2
    (result is assigned to a2)

aspl> a12 = f& a1 a2
    (a12 is assigned the intersection of a1 and a2)

aspl> v
    (print the variables)

 

■ Definining a Function

ASPL functions are defined with the DEF FN. An ASPL function is just an alias to an ASPL expression.

(* it does comparable to a function of a procedural computer language.)

It is convenient to define functions of your own. Possible names for these are FN followed by a word.

These are stricter about the brackets: the argument must be enclosed in brackets.

You define a function by putting DEF statement somewhere in the program. For instance, here is the definition of a function:

DEF FN cmp2sets := {gU {g\, %%1 %%2}{g\, %%2 %%1}{g&, %%1 %%2}}

This defines function cmp2sets() to compare two set variables.

The %%1 %%2 are place holders for the arguments of the function and will be replaced with the actual parameter values of the caller.

After the := sign comes the actual definition of the function. This can be any expression, and it can also contain

any replacement-arguments (in this case %%1 and %%2) as though they were ordinary variables.

When you have entered this line, you can invoke the function just like one of ASPL own functions, by typing its name, FN cmp2sets followed by the arguments between parenthises. Remember that when you have defiined a function yourself, the argument must be enclosed in parenthises. Try it out few times:

FN cmp2sets(a1,a2)

You cannot enclose an expression as the argument of a function, however you can pass identifiers like set variables, here is an example:

a12 = f& a1 a2

a23 = f& a2 a3

FN cmp2sets(a12,a23)

Only one type of information can be passed from the calling program to the called program as parameter data. These are called actual parameter values, or arguments, to distinguiish them from the formal parameter values. Actual parameter values are all strings.

The FN function must indicate a list of the parameters that are to be used. The list is written in parentheses following the name of the FN function.

The parameter list organiization should be as uniform as possible so that any reader can understand it

 

■ Defining a Quotient Relation

The Q command displays the quotient relation table that are precoded by the user.

Most of the known predicates that can be affixed to operators, following the tick `, has been already coded within ASPL.

For these (common denominator between all grouping class attributes: mtime chksum) you can browse and skim through these operators.

You can define your own quotient relation by using Q DEF as it is convenient to define quotient-relations of your own. Possible names for these are /~ followed by a word.

f&/~r4

The / is and ~ is and r4 is the relation

aspl> q

 

■ ASPL Workspace

ASPL symbol table and everything meta or info or not meta goes in ASPL workspace .........

 

Example 2.1.2

A variable can also be created by other operations like the pop operator.

aspl> a1 = ggdir /tmp/aa1

 

ASPL variables cannot be deleted, however they can be reassigned.

①   On the shell prompt before starting ASPL interpreter export ASPL_CONFIG

export ASPL_CONFIG=$HOME/WS,WS1,10,10,10,1000,30,2,0,1,0

②   Start ASPL

③   Type envvar at ASPL prompt to have ASPL print the environment variable

aspl> envvar
    (ASPL will print the environment variable)

 

Operation 2.1.1

①  aspl> c123 = c& a1 a2 a3
    (c123 is assigned all checksums intersections of a1 a2 a3)

②  aspl> adisplay c123
    (print out c123)

aspl> av c123
    (view internals of set variable c123)

③   Just dump the rest to a file

AS BEING SET IN THE SHELL:
--------------------------
ASPL_CONFIG=/root/WS,WS3,10,10,10,1000,30,2,0,0,0