1.2 Using the betaenv Library

The basic structure of betaenv is realized by means of the Mjølner fragment system. It is as follows:

BODY 'betaenvbody'
--- betaenv: descriptor ---
(# ...
(* A lot of useful patterns *)
...
theProgram: @<<SLOT program: descriptor>>;
<<SLOT lib: attributes>>
...
do theProgram
#)

The program slot must be filled by the user and can have the following form:

ORIGIN '~beta/basiclib/betaenv'
--- program: descriptor ---
(# 
do 'This is a small BETA program' -> puttext
#)

lib slot

The lib slot makes it possible to add attributes to betaenv. An example of this is the following which might be in a file called stack.bet:

ORIGIN '~beta/basiclib/betaenv'
--- lib: attributes ---
stack: 
(# push: (# e: @integer enter e do ... #);
   pop: (# e: @integer do ... exit e #);
   empty: ...
   ...    
#)

The stack can then be used as follows:

ORIGIN '~beta/basiclib/betaenv';
INCLUDE 'stack'
--- program: descriptor ---
(# s: @stack
do 7 -> s.push; 
   s.pop -> putint;
#)


Basic Libraries - Reference Manual
© 1990-2002 Mjølner Informatics
[Modified: Wednesday October 18th 2000 at 13:14]