May 2000

Set Operations

Set Operations are not implemented in KMAL. Furthermore,the syntax of set operations may not be exactly what is shown here.

The major difference between KMAL, and most other popular languages is the lack of loop structures. To replace loops KMAL has set operations.

Here is the basic structure of a set operation.

As with SQL a query is broken down into clauses. The first clause, the execute clause, is the name of the function that is executed for each object returned by the conditions below it. The parameters have two portions, the right hand side is the name of the parameter, and is also used as an alias for the conditional expressions below. The left handle side is the name of the set that is input to the query. We note that the type of object stored in the set must match the type of the parameter expected.

The where clause acts as a filter on the input sets. Using the alias names, the attributes of the objects are tested against constants, they are removed from further processing if they do not match. More complex filtering can be done by using single row functions to compute a new attribute, and then using where to filter on the result.

The join clause compares the attributes from two different sets. The object pair are passed to the execute clause only if their attributes match as per the clause definition. Like the where clause, more complex rules for joins can be perfumed by joining on the results of using single row functions instead.

This is a simple set operation. We will simply print all the strings in the SetOfStrings object.

Note that the ordering of the strings, and therefore the printout is not deterministic. This is a particularly bad example to begin with because, depending on how print is implemented, you could get just a mashed series of characters on your screen as each string fights for display resources.