6 ms·
In Perl, no such surprises, because the operators for string concatenation and arithmetic addition are different, as they should be. Motto: different things sho
by bmn__ 9y ago
In Perl, no such surprises, because the operators for string concatenation and arithmetic addition are different, as they should be. Motto: different things should look different.
Overloading + is a huge design mistake in many languages and a source of bugs.
$ perl -E'say 1 + 2 . "=" . 1 . 2'
3=12
$ perl -E'say 1 + 2 . "=" . (1 + 2)'
3=3
$ perl6 -e'say 1 + 2 ~ "=" ~ 1 ~ 2'
3=12
$ perl6 -e'say 1 + 2 ~ "=" ~ 1 + 2'
3=3