News for hackers. Stuff that matters.
Re:My Opinion on “5” == 5 by llimos on Thursday July 29, 2021 @01:00PM (#27998646)
PHP also has a nice thing I wish more languages had, which stops you shooting yourself in the foot due to this - the concatentaion operator (.) is different from addition (+).

So "5" + 1 is 6, just as 5 + 1 is 6.

Re:My Opinion on “5” == 5 by coding123 on Thursday July 29, 2021 @01:17PM (#27998859)
The reason other languages don't have that is very few languages will implicitly convert that "5" to a number. Instead other languages generally only have the implicit convert to string as it's considered less magical.
Re:My Opinion on “5” == 5 by perl4ever on Thursday July 29, 2021 @01:06PM (#27998720)
I can't think offhand of a language that does overload + for strings by default.

  Perl uses .
  Oracle SQL uses ||
  Microsoft SQL and VBA use &
  C obviously doesn't use +.
  Neither does Pascal.
  Power Query doesn't.
Re:My Opinion on “5” == 5 by poizan42 on Thursday July 29, 2021 @02:46PM (#27999917)
> Microsoft SQL and VBA use &

Nope, Microsoft SQL uses +.

* https://docs.microsoft.com/en-us/sql/t-sql/language-elements...

* https://i.imgur.com/7z81o8t.png

* https://i.imgur.com/VDR9qer.png

> C obviously doesn't use +.

But C++ does for std::string.

> Neither does Pascal.

Original Pascal didn't, but I think most modern Pascals do (e.g. Object Pascal known from Delphi).

Re:My Opinion on “5” == 5 by perl4ever on Friday July 30, 2021 @12:18AM (#28004388)
>Nope, Microsoft SQL uses +.

I was referring to Access.

>Original Pascal didn't, but I think most modern Pascals do

I'm pretty sure concat() was used in THINK and Metrowerks Pascal in the 90s.

Re:My Opinion on “5” == 5 by int_19h on Thursday July 29, 2021 @04:29PM (#28001093)
Pascal does, at least in all the more common dialects.

VBA (and VB in general) overloads "+" for strings in addition to providing "&", the difference being mostly in what gets converted to what in various situations: https://docs.microsoft.com/en-us/office/vba/language/referen...

Re:My Opinion on “5” == 5 by perl4ever on Saturday July 31, 2021 @10:18PM (#28023222)
Is there any reason anyone in their right mind would use + that way in VBA?
Re:My Opinion on “5” == 5 by int_19h on Monday August 02, 2021 @11:34AM (#28038015)
I've seen plenty of code in VBA and VB6 that does so. I think it stems mostly from & being a late addition to BASIC (earlier BASICs only had +).
Re:My Opinion on “5” == 5 by Frondo on Thursday July 29, 2021 @01:09PM (#27998760)
C# does, as do quite a few others. Heh, this is kind of interesting:

https://www.rosettacode.org/wiki/String_concatenation

Re:My Opinion on “5” == 5 by dahfizz on Thursday July 29, 2021 @01:21PM (#27998901)
Java and Python, from the top of my head, allow "str1" + "str2"
Re:My Opinion on “5” == 5 by rspeele on Thursday July 29, 2021 @01:20PM (#27998886)
C#, GoLang, Javascript, Python, and Ruby are several.

Python and Ruby even overload *, for the dubiously useful construction:

"hello" * 3 == "hellohellohello"

Re:My Opinion on “5” == 5 by infogulch on Thursday July 29, 2021 @01:47PM (#27999232)
I like Julia's standard string concat which subverts a Python user's intuition: "string1" * "string2" == "string1string2". Why? Because monad.
Re:My Opinion on “5” == 5 by Zababa on Thursday July 29, 2021 @01:24PM (#27998918)
JavaScript, Python, Ruby, Go all use +.