To clarify an important difference: Specifying a method without a parameter list generates code without parenthesis following the method name, where as specifying a method with an empty parameter list generates code with parenthesis but no parameters. Danish uses functional notation, which may be confusing with the use of an object oriented program such as Java. The point of confusion comes with a member function, which in functional notation returns an object type and takes an object type as a parameter. To illustrate, a member function 'class.function(value)' is actually 'class = function(class, value)'.
"return type" "function name"
OR
"return type" "function name" ("type list")
Curly braces are used to indicate the location of the class parameter; they are placed around the parameter which represents the instance of which the function is a member. If a member is a mutator class, the return type is in effect the class itself; this is indicated by enclosing the return type in braces.
{class} function ({class}, Id, value)
>would be the form for a mutator function of the class
(changes the class/object itself, ex: add)
Id newId (int)
>would be the form to return an Id type with an int as
a parameter
class newClass ()
>would be the form to create a new instance of a class
attr nullAttr
>would be the form for a function with no parameters
{class} function (int)
>is invalid, since this must have the class as a parameter
Danish performs strong type checking; it supports overloaded function names so a single function name may have multiple signatures as long as they are distinguishable. The wildcard '*' is a valid parameter type name and will accept any variable of any type.
When an axiom fails, the printing function (if it exists) is invoked for the failing lvalue and rvalue.
Integers are specified by an optional negative sign followed by one or more digits; type 'boolean' can be either 'true' or 'false; Strings are enclosed in double quotes, chars in single quotes.
RETURN_TYPE OPERATOR OPERANDS NOTES
boolean == (*,*) -equal
boolean && (bool, bool) -and
boolean ^^ (bool, bool)
boolean != (*,*) -not equal
boolean || (bool, bool) -or
int + (int, int) -addition
int - (int, int) -subtraction
int * (int, int) -multiply
int / (int, int) -division
int % (int, int) -modulus
NOTE: operand * signifies any type.
Built in infix functions are listed above. Evaluation of all expressions in strictly right to left; there is no precedence. 'a == b ? c : d' will be interpreted as 'a == (b ? c : d)'. The use of parentheses is highly recommended. The only other built in function is 'boolean not (boolean)'.
Conditional evaluation is performed with the ternary operator:
"if boolean" ? "then clause" : "else clause".
>adapted from Daistish++ manual, by Hughes, September 25, 1995.