News for hackers. Stuff that matters.
Re:Why operators are useful (2019) by hansvm on Wednesday February 26, 2020 @11:06AM (#22424209)
It's mostly true that operators are equivalent to functions, but there's an important distinction at parse time too for most languages.

You can have functions named foo, bar, and foobar, but without some sort of convention (usually whitespace or other delimiters) it isn't possible to look at the string foobar and identify whether this is supposed to refer to the single function by that name or to whatever having foo and bar adjacent means in your language (probably composition or application).

Contrast that with operators like +, which serve as delimiters by themselves and can be unambiguously placed next to other function names because they're drawn from a different character set.

Whether that convenience is worthwhile is up for debate, but I think it would be surprising to type a+b and get some kind of parse error that can be rectified just by typing a + b instead.

Re:Why operators are useful (2019) by clarry on Wednesday February 26, 2020 @12:48PM (#22425338)
> Whether that convenience is worthwhile is up for debate, but I think it would be surprising to type a+b and get some kind of parse error that can be rectified just by typing a + b instead.

I kinda prefer that a+b lexes as one identifier: a+b. Also rabbits-are-cute.