Expressions are evaluated from left to right.
Parentheses can be used to group expressions. For instance, the previous expression is equivalent to 1 + (2 * 3). If the other interpretation is desired (1 + 2) * 3 can be used instead.
Basic CM Expressions
if as
if (z as TaggedComponent) return z.tag;
If statement with built in dynamic cast, z gets the more specific type within the if statement (positive) scope.
#:package
symbol pkg = #:package;
Resolves to the current package (e.g. the one stated at the top of your .cm source file).
#:package : caller eval
public void foo(symbol pkg=#:package : caller eval) { pln(pkg); }
Here the #:package is evaluated in the calling context.
#:src
SrcRef source = #:src;
Works as #:package above, but returnes the SrcRef at the call site (#:src is always caller eval).
Special Value Expressions
Units
double a = 12 mm; double a = 12 cm; double a = 12 dm; double a = 12 m; double a = 12 inch; double a = 12 feet;
(deg) angle
angle a = 30deg;
(x, y, z) point
point p = (1, 2, 3.14); point2D p = (1, 3.14); pointI p = (1, 2);
(yaw, pitch, roll) orientation
orientation p = (30deg, 90deg, 280deg);
Comments
0 comments
Please sign in to leave a comment.