Please enable JavaScript to view this site.

Added February 2019

The #+ and $+ operators may be used as unambiguous alternatives to the + operator, eliminating any doubt as to whether the operation will be addition (#+) or concatenation ($+). This is particularly useful in the context of DYNSTRUCTs, since the compiler is unable to know at compile time the types that the members will be bound to at run time, which could easily lead to confusion in a statement like:

foo.bar = a + b         ! addition or concatenation?

If foo is a DYNSTRUCT, then the compiler will treat foo.bar as a string (without knowing its eventual bound type). So that would cause it to compile the + in the above statement as concatenation.

To avoid such confusion (and logical errors), use the unambiguous operators, e.g.:

foo.bar = a #+ b        ! addition

foo.bar = a $+ b        ! concatenation

 

Note that since "$" could be a suffix on a variable, the $+ operator must be preceded by a delimiter (preferably a space for clarity), else the compiler may try to associate it with the prior variable name, i.e.

a = b$+c                ! compiler reads as b$ + c

a = b $+ c              ! compiler reads as b $+ c

a = b$$+c               ! compiler reads as b$ $+ c

 

Note that these unambiguous operators achieve the same objective as the casting functions NUMEXPR(expr) and STREXPR$(expr). You can freely mix and/or combine them for clarity, but generally only one method of resolving ambiguity is necessary.

History

2019 February, A-Shell 6.5.1654, compiler edit 890:  Added to A-Shell.

Created with Help+Manual 9 and styled with Premium Pack Version 5 © by EC Software