String CONCATINATION Operator

The + operator is a special context sensitive binary (infix) operator that behaves as the integer ADDITION operator when its left hand operator is an integer and as the string CONCATINATION operator when its left hand operand is a string.

The + operator expects the types of both its left and right hand operands to match. If they do not, the right hand operand is coerced to match the type of the left hand operand.

If the left hand operand is an integer and the right hand operand is a string, then the right hand operand is automatically coerced to an integer before the integer ADDITION operator is applied.

If the left hand operand is a string and the right hand operand is an integer, then the right hand operand is automatically coerced to a string before the string CONCATINATION operator is applied.

 

syntax:

	<left_expr> + <right_expr>

<left_expr> and <right_expr> are refered to as the left and right operand respectively and may themselves be simple values or complex expressions.

e.g.
	integer addition

	0x1234 + 16			yields 0x1244

	10 + 3				yields 13

	(5 * 7) + 8			yields 280

	----------------------

	string concatination

	"0x1234" + 16			yields "0x123416"

	"(5 * 7)" + 8			yields "(5 * 7)8"

	----------------------

	to force a number to a string

	"" + 123			yields "123"

	----------------------

	beware or evaluation order


	2 - "3" + "5"			is equivalent to (2 - 3) + 5 which yields 4

	2 - ("3" + "5")			is equivalent to 2 - "35" which yields -33

	"2" + (3 + 5) + 7		is equivalent to "2" + "8" + "7" which yields "287"

	"2" + (3 + "5") + 7		is equivalent to "2" + (3 + 5) + "7" which yields "287"

	"2" + ("3" + 5) + 7		is equivalent to "2" + "35" + "7" which yields "2357"