6 ms·
Changing the declaration syntax could be a big improvement, but changing assignment operators is a bad idea. (summary: a=b now tests for equality, a:=b is assig
by tlb 17y ago
Changing the declaration syntax could be a big improvement, but changing assignment operators is a bad idea. (summary: a=b now tests for equality, a:=b is assignment). I know if I start using a language where a=b means equality test, I'm going to make that mistake in Javascript, Python, and every other language I use.
When designing a new language, remember that people spend most of the time using other languages. So don't be gratuitously incompatible in dangerous ways.
- gte910h 17y agoYeah, := should be assigns, and == should be equal, and = should be an error.
- MichaelGG 17y agoThat does happen to me. F# uses = for equality and <- for assignment, and I end up doing the same in C#. Fortunately in C#, only boolean expressions can be used in predicates so it hasn't caused me any more than a compilation error yet.
- jimbokun 17y agoGo claimed := as the initialization operator, leaving = and == as before. Since you should avoid assignment after initialization when possible, anyway, I suspect = could be avoided altogether in a lot of code.
- contextfree 17y agoSomebody needs to take a stand at some point. The C-style equality and assignment operator conventions are awful things.
- wheels 17y agoThe most honerous case of that that I've run into is in the ChucK programming language (for audio synthesis, MIDI processing, etc.). In general it's quite nice, but the assignment operator is "=>" and the assignee goes on the right, e.g.: 140 => int beatsPerMinute; http://github.com/scotchi/Chuckery/blob/master/MidiDelay.ck http://github.com/scotchi/Chuckery/blob/master/MidiDelay.ck It's really close to all of the other Java-ish family of languages for the most part, but I find myself having to fix a dozen auto-piloted assign errors every time I try to run the code.