3 Static Types
In this and subsequent syntax specifications, changes to specifications as described in section 2 are in boldface.decl ::= let_decl | tp_decl | type_ext_decl | object_decl | obj_ext_decl
| predicate_decl| disjoint_decl | cover_decl | divide_decl
| signature_decl | method_decl
| field_sig_decl | field_decl | precedence_decl | include_decl | prim_decl
The following example illustrates some of the extensions:
object
list;method
is_empty(l@:list):bool { l.length = 0 }signature
length(l:list):int;signature
do(l:list, closure:&(int):void):void;signature
pair_do(l1:list, l2:list, closure:&(int,int):void):void;method
prepend(x:int, l@:list):list {object inherits
cons { head := x, tail := l } }method
copy_reverse(l:list):list {let
var
l2:list := nil; do(l, &(x:int){ l2 := prepend(x, l2); }; l2 }representation
consisa
list;field
head(@:cons):int;field
tail(@:cons):list;
Generated with Harlequin WebMaker