User guide
2.2. EXPRESSIONS 19
Here, E
1
points to the fields of an object, wit h the convention th at its ze-
roth field (E
1
!0) i s a pointer to the methods vector. Element E of this
vector is ap plied to the given set of arguments. Nor m a ll y, E is a mani-
fest con st ant. An example program illustrating method calls can be found in
BCPL/bcplprogs/demos/objdemo.b in the BCPL di st r i b u t i on system (see Chap-
ter 12).
2.2.5 Prefixed Expression Operators
An expression of the form !E returns the contents of the memo ry word pointed
to by the val ue of E.
An expression of the form @E returns a pointer to the word sized memory
location specified by E. E can only b e a variable name or an expression with
leading operator !.
Expressions of the form: +E, -E, ABS E, ~E and NOT E return the result
of applying t h e given prefixed operator to the value of the expression E. The
operator + returns the value unchanged, - r et u r n s the integer negation, ABS
returns the absolute value, ~ and NOT return t he bitwise complement of the value.
The fol lowing floatin g point prefixed operators are allowed: FLOAT, FIX, #ABS,
#+ and #-. FLOAT E converts the integer E to its floating point representation.
FIX E converts the floating point value E to its closest integer representation.
#ABS E r et u r n s the absol u t e value of the floating point number E, and #+ and #-
perform monadic plus and minus on floating point values.
2.2.6 Infixed Expression Operators
An expression of the form E
1
!E
2
evaluates E
1
and E
2
to yield respectively a
pointer, p say, and an integer, n say. The value returned is the contents of the
n
th
word relative to p.
An expression of the form E
1
%E
2
evaluates E
1
and E
2
to yield a pointer , p
say, and an integer, n say. The expression returns a word sized result equal to
the unsigned byte at position n relative to p.
An expression o f the form K OF E accesses a field of consecutive bits
in memory. K must be a manifest constant ( see section 2.2.10) equal to
SLCT len:shift:offset and E must yield a pointer, p say. The field is contained
entirely in the word at position p+offset. It has a bit length of len and is shift bits
from the right hand end of the word. A length of zero is interpreted as the longest
length possible consitent with shift and the word length of the im p l em entation.
The operator ⁀:: is a synonym of OF. Both may be used on right and left hand
side of assignments statements but not as th e operand of @. When used in a
right hand context the selected field is shifted to the right hand end of the result
with vacated posit io n s, if any, filled with zeros. A shift to the left is performed