Binary arithmetic expression with binary_expression<-left
and binary_expression<-right
operants. Class binary_expression
has the subclasses
+ Addition - Subtraction and negation
PCE expression objects are first of all designed for supporting graphics calculations. The intermediate results are calculated in fixed-point arithmetic (1/1024 resolution). The result is rounded to the nearest integer value.
Binary expressions are used by class = for the definition of equations used by class spatial. The are also used by class handle and class region to express locations in terms of the dimensions of a related graphical object. Finally, they may be used as function objects in methods.
Note that type conversion converts function objects (and thus also binary expressions) into the value they evaluate too. This implies that
send(Box, size, size(W+2, H+2))
Is a comfortable way to do (graphics) calculations in PCE/Prolog. It must be noted that
W1 is W + 2, H1 is H + 2, send(Box. size, size(W1, H1))
is, in generally faster as the first example creates two PCE expressions evaluates then and then destroys them again.
Bugs:
Evaluation of expressions is written in C, bypassing the message passing of PCE. This implies the user cannot define new expression classes.
-left
<-left
and binary_expression<-right
operator. As class binary_expression
itself does not define evaluation there is little use in creating
instances of this class.
|number|real?- get(x + 5, value, x=3, X). ==> X = 8
Note: in this example we can simply write x instead of new(X, var(x))
as x is the name of a predefined var
object. See class var.
See also =<-var.
= <-var.