Re:We don't need runtime type checks
by onaworkcomputer on Thursday March 03, 2022 @03:32PM
(#30546544)
Rasmus borrowed this distinction from Larry Wall, since PHP was originally implemented in Perl (which also uses + for addition and . for string concatenation).
The neat thing about PHP and the + operator is that you can sometimes trick the interpreter into doing math on the underlying bytes of the string: http://dominic-mulligan.co.uk/wp-content/uploads/2015/05/SRE...
Re:We don't need runtime type checks
by TazeTSchnitzel on Thursday March 03, 2022 @03:36PM
(#30546596)
There's nothing improper about having a separate operator for concatenation.
Re:We don't need runtime type checks
by throw_m239339 on Thursday March 03, 2022 @03:45PM
(#30546721)
> There's nothing improper about having a separate operator for concatenation.
Only to monopolize that operator to then have to use "->" for method call. C/C++ do that because of dereferencing. There is no need for that in PHP OO, all objects are passed by pointer to functions or methods.
Meh, other languages manage to assign multiple meanings to single tokens and depend on context to resolve ambiguity. PHP's issue here is that it refuses to do so, which is how we ended up with the backslash as a namespace delimiter.
Only because Rasmus didn't know how to design and implement a "proper" programming language. This isn't a intended feature, it just made parsing easier for him.