Logiweb(TM)

7.7.10 Built in operators

Prev Up Next Page 206 of 800 Search internet


The base page defines the built in operators listed at the end of this page. The list happens to include all built in operators lgwam knows.

Some comments may be appropriate:

x .and. y, x .or. y, and if x then y else z
These constructs are not left-right: even when evaluation of x results in a non-exception, the constructs do not always compute y.
x catch and x catching maptag
These constructs are not relaying: even if evaluation of x results in an exception, the given constructs return a pair and a tagged map, respectively.
print ( x ), spy ( x ), timer ( x ), and trace ( x )
These constructs have side effects when executed by lgwam. The constructs return the strings 'print', 'spy', 'timer', and 'trace', respectively. Thus, they are still pure functional in the sense that they are univocal. Side effects should only be used for debugging since side effects are not portable: the four constructs above have particular side effects when executed on lgwam, but other Logiweb abstract machines might not implement those side effects. When writing Logiweb programs which are supposed to interact with their surroundings, use Logiweb machines instead of side effects. Note that side effects can only transport information from program to surroundings. Univocality makes transport the other way impossible.
x .then. y
This construct computes x, discards the result, computes y, and returns y. The construct is an ordinary eager left-relaying construct so if x returns an exception, that exception is relayed and y is not computed. The x .then. y construct may be useful in connection with constructs which have side effects.
map ( x )
This is the only operator which is not eager but which can nevertheless be used in eager programs. There is a restriction, however: to be fit for optimization, the term x is not allowed to contain free variables. If you want something like map ( true :: x ) in you program, you should instead use map ( \ y . true :: y ) apply x maptag. In the latter expression, x maptag puts a maptag on x, then the x apply y operator does functional application under the maptags, and then ( \ y . true :: y ) ' x beta-reduces to true :: x under the maptag.
YY
The fixed point operator YY is the only built in construct which cannot be used in eager definitions.
bottom
This is an optimized version of an infinite loop. bottom is defined by a definition whose right hand side loops indefinitely when evaluated. Implementations have to be 'partially correct' in the sense that if they return a value, they must return the correct value. In this context, an exception counts as a value like any other value, so if a construct returns an exception, it must return the right exception. The right hand side of the definition of bottom never returns a value, not even an exception. Hence, evaluation of bottom is not allowed to return a value, not even an exception. When lgwam executes bottom it writes This takes forever, says goodbye, and exits. Thus, bottom is a certain death operator: if your program evaluates it, your program is dead. There is no counter for this. If you want your program to be able to resurrect, you must use exceptions rather than the definitive death operator bottom.
true, quote x end quote, strings, and page symbols
In addition to built in constructs, eager definitions may use the fundamental constructs truth true, Gödel brackets quote x end quote, strings, and page symbols.

The list of built operators reads:

x %0 x %0
x %1 x %1
x %2 x %2
x %3 x %3
x %4 x %4
x %5 x %5
x %6 x %6
x %7 x %7
x %8 x %8
x %9 x %9
x * y x * y
x + y x + y
x - y x - y
x .and. y x .and. y
x .or. y x .or. y
x .then. y x .then. y
x :: y x :: y
x < y x < y
x <= y x <= y
x = y x = y
x > y x > y
x >= y x >= y
x apply y x apply y
x boolp x boolp
x catch x catch
x catching maptag x catching maptag
x div y x div y
x head x head
x intp x intp
x is bool : y x is bool : y
x is int : y x is int : y
x is map : y x is map : y
x is object : y x is object : y
x is pair : y x is pair : y
x mapp x mapp
x maptag x maptag
x mod y x mod y
x norm x norm
x objectp x objectp
x pairp x pairp
x raise x raise
x root x root
x tail x tail
x untag x untag
%% %%
( x ) ( x )
+ x + x
+x +x
- x - x
-x -x
.not. x .not. x
Base Base
LET x BE y LET x BE y
ash ( x , y ) ash ( x , y )
bottom bottom
bt2byte* ( x ) bt2byte* ( x )
bt2vector* ( x ) bt2vector* ( x )
bt2vector ( x ) bt2vector ( x )
ceiling ( x , y ) ceiling ( x , y )
destruct ( x ) destruct ( x )
evenp ( x ) evenp ( x )
exception exception
false false
floor ( x , y ) floor ( x , y )
half ( x ) half ( x )
if x then y else z if x then y else z
integer-length ( x ) integer-length ( x )
logand ( x , y ) logand ( x , y )
logandc1 ( x , y ) logandc1 ( x , y )
logandc2 ( x , y ) logandc2 ( x , y )
logbitp ( x , y ) logbitp ( x , y )
logcount ( x ) logcount ( x )
logeqv ( x , y ) logeqv ( x , y )
logior ( x , y ) logior ( x , y )
lognand ( x , y ) lognand ( x , y )
lognor ( x , y ) lognor ( x , y )
lognot ( x ) lognot ( x )
logorc1 ( x , y ) logorc1 ( x , y )
logorc2 ( x , y ) logorc2 ( x , y )
logtest ( x , y ) logtest ( x , y )
logxor ( x , y ) logxor ( x , y )
map ( x ) map ( x )
norm x norm x
notnot x notnot x
object ( x ) object ( x )
print ( x ) print ( x )
round ( x , y ) round ( x , y )
spy ( x ) spy ( x )
timer ( x ) timer ( x )
trace ( x ) trace ( x )
truncate ( x , y ) truncate ( x , y )
vector ( x ) vector ( x )
vector-norm ( x ) vector-norm ( x )
vector-empty ( x ) vector-empty ( x )
vector-index ( x , y ) vector-index ( x , y )
vector-length ( x ) vector-length ( x )
vector-prefix ( x , y ) vector-prefix ( x , y )
vector-subseq ( x , y , z ) vector-subseq ( x , y , z )
vector-suffix ( x , y ) vector-suffix ( x , y )
vector2byte* ( x ) vector2byte* ( x )
vector2vector* ( x ) vector2vector* ( x )
vt2byte* ( x ) vt2byte* ( x )
vt2vector* ( x ) vt2vector* ( x )
vt2vector ( x ) vt2vector ( x )
YY YY
compile ( x ) compile ( x )
ripemd ( x ) ripemd ( x )
sl2rack ( x ) sl2rack ( x )
rack2sl ( x ) rack2sl ( x )

Prev Up Next Page 206 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05