mita
mita copied to clipboard
Strings can be concatenated using += but not by using infix addition
In Mita, the following code is legal:
var str1 = 'Hello ';
var str1 += 'World';
but the following code is not legal;
var str1 = 'Hello ';
var str1 = str1 + 'World';
Semantically speaking, += is an arithmetic operator, and naturally expected to be a shorthand for an infix addition between two operators. Hence, the second code fragment would be expected to be legal.
I am not sure if this is a bug or intended. If it is intended, I would deem this a usability issue, since code such as the code fragment below, which is not yet possible in Mita, would be natural to write in most modern languages that also feature the +=
operator for strings.
var firstName = 'Alexander';
var lastName = 'Sawtschuk';
var fullName = firstName + ' ' + lastName;
this should be fixed in #320
this should be fixed in #320
Sadly no, especially since general concatenation of buffers is more complicated than appending, for example if source and destination are the same buffer.
In general this could be solved by transforming a = b + c;
, with no constraints on identity of a
, b
and c
, to this:
var b_copy = b;
b_copy += c;
a = b_copy;