Shortcut Operators #+= and $+=

Language enhancement, compiler edit 934 : Add unambiguous shortcut operators: #+= and $+=. These are equivalent to the existing shortcut operator += except that they unambiguously specify either addition or concatenation, respectively, regardless of the destination type. For example:

map1 a$,s,10

dimx $num, ordmap(varstr;varstr)

map1 n,f

 

a$ += 1             ! sets a$ = "1"

a$ += 1             ! sets a$ = "11", e.g. "1" + "1"

a$ #+= 2            ! sets a$ = "13", e.g.  val("11") + val("2")

? "a$ = ";a$        ! "13"

 

$num("one") = "1"                  ! sets $num("one") = "1"

$num("one") #+= "1"                ! sets $num("one") = "2"

$num("one") #+= $num("one")        ! sets $num("one") = "4"

? "$num(""one"") = "; $num("one")  ! "4"

 

n += 1              ! n = 1

n #+= $num("one")   ! n = 5, e.g. 1 + val("4")

? "n = ";n          ! 5

 

Note that these new unambiguous shortcut operators do not require an update to the run time system as they are compiled down to the traditional and equivalent long form of the operations.