© Jørgen Steensgaard-Madsen, Copenhagen, 2006
Statements                                                  
 
   

Statements are commonly known from several programming languages. Examples are if- and while-statements. Conceptually these are just applications of operations, but it may help to present them in a traditional way.

Syntax overview

An operation signature associates a name with a list of clause descriptions and possibly a result type. An application of an operation is called a command.
Function arguments are simple examples of clauses, as are the branches of a conditional command. In more complex cases a clause may be the scope of some descendants of the command operation. Different clauses will usually have different descendants. Saying clause ... is evaluated is short for computation expressed by clause ... is performed.
A clause description is a signature itself: it associates a name of the clause with a list of signatures of descendants. Detailed information about the language of signatures and commands will have to be found elsewhere.
Other statements may not be as familiar, but they certainly belong in this category.

Semantics

[ loop OF w[Body ... : w] : void ]

The computation of the Body clause is repeated until execution of operation end, which has a signature (represented by the ellipsis above):
Note that a label may be associated with a Body clause:
loop A{ ... loop B{ ...; A.end; ... } ... }

where execution of A.end will cause the outer loop to terminate.

Semantics

[ upto OF W
     (n:int)
     [Body ... : W] : void ]

Signatures (...) of operations introduced in a Body clause are:

Semantics

[ induction OF Problem,Result
     (Initial:Problem)
     [Break_down ... : Result] : Result ]

Use of induction can be as follows:
induction (L) P{ if (P==[],1,hd(P)*result(tl(P))) }; 

If L is a value of type int List the computation finds the product of elements in L. The proof of this claim goes as follows:
Let P be a list and P P the product of the elements of P.
By induction on the length of P we find
  1. If P is empty, P P is 1, as found by the computation.

  2. Otherwise, by assumption P tl(P)= result(tl(P)) is the product of elements of tl(P), so the products of elements of P is hd(P)*P tl(P), as found by the computation.

Thus we conclude that for any list of finite length
P L= induction (L) P{ if (P==[],1,hd(P)*result(tl(P))) }
Clause:   Break_down of operation induction
Intended to tell how to solve a given problem under the assumption that simpler problems can be solved by means of an auxiliary operation.

Semantics

[ iterate OF Result,State
     (S:State)
     [Next ... : State] : Result ]

Supports computations by sequences of states S0, S1, S2, ... that terminates and extracts a result from some final state Sn.
An example corresponding to the one for induction is
iterate((1,L)) X{if(snd(X)==[],fst(X),(fst(x)*hd(X),tl(X)))}

which may compute as follows: (1,[2,3,5]),(2,[3,5]),(6,[5]),(30,[]) and return 30.
Clause:   Next of operation iterate
Intended to compute a next state Si+1 from Si.

Semantics

[ with OF V,W
     (E:V)
     [Body ... : W] : W ]

Pattern of use is: { with(cpu_heavy(n)) x; ... x-y ... }. It is intended to avoid recomputation of intermediate results without resort to mutable variables.
Clause:   Body of operation with
Computes the final result using a name for the intermediate one.

Contents

·Demo language
Implementation tool
Copyrights


General properties
Applications
·Contributions
Installation


Somefix operators
·Statements
Predefined type operators
Mutable variables
Functions for mathematics
File operations
Processes and connections
Misc. utilities
New type operators
Top-level entities



File translated from TEX by TTH, version 3.33.
On 18 Oct 2006, 16:47.
SourceForge.net Logo