Saturday, June 04, 2005

More about DALI

Assignment operators

The traditional := ('becomes') is retained, but several new assignment operators are available in addition:

m= (might be equal to) - allows non-definite arithmetic; that is, arithmetic using numbers whose values are uncertain. For example:
x := 2;
x m= 3;

is the DALI equivalent of the phrase "a is 2 ... but then again, it might be 3". Instead of forcing the user to decide on which value x should take, both values are specified. The DALI language will chose whichever it feels is the more appropriate at run-time.

~= (is not equal to) - this must not be confused with the logical operator NOT. An example of the use of ~= is:
ps ~= 4;
writeln (ps);
ps := ps + 1;
writeln (ps);

The first writeln may print any value except for the integer 4. The second will print any value except for the integer 5.

Logical Operators

AND, OR, NOT, EXOR (exclusive or) are implemented as usual. Added operators are EXNOT and EXAND.

Program flow

Many users of Pascal have expressed the desire for a more powerful form of the GOTO statement. However, the designers of DALI carried out careful studies into programming habits, and discovered that almost all GOTOs were put in retrospectively, from some further part of the program. Therefore, DALI implements the vastly more useful COMEFROM statement.

For example:
label test;
if (a=1) then ...
{rest of program}
comefrom test;

The implementation of the COMEFROM statement requires that the language be either compiled or pre-interpreted, so that the necessary comefrom stack can be built.

while ... do - This has now been extended to include statements of the form:
while (condition) don't
{program block}

The additional UNLESS clause allows extra conditions to be added as an afterthought. For example...

while (a > -100) do
    b := 1/a;
    a := a - 1
unless (a=0);

Expression Evaluation

The new function eval(words) allows user-entered words to be arithmetically evaluated. Evaluation is quite slow, especially when type "mindboggling" is used. An extremely fast expression evaluation function is also provided; the guess() function totally ignores its arguments, and guesses the answer. An extended implementation is planned for future development, which may include the inspiredguess() function. This should return a value of the right type.

More another time ...