Re:The ecosystem of the Go programming language
by colejohnson66 on Monday March 22, 2021 @05:47PM
(#26547683)
Speaking of reserved words, I remember reading once about how PL/I had no reserved words. Which has the nice quirk that this is valid code:
IF IF = THEN THEN THEN = ELSE ELSE ELSE = ENDIF ENDIF
...assuming IF, THEN, ELSE, and ENDIF are all variables.
Re:The ecosystem of the Go programming language
by gher-shyu3i on Monday March 22, 2021 @04:38PM
(#26546619)
true := false is valid golang code
Re:The ecosystem of the Go programming language
by DangitBobby on Monday March 22, 2021 @11:08PM
(#26550569)
Wow, WTF? Why are true/false not reserved?
Go carefully touts how few reserved keywords it has, but I think it would actually be a simpler to reason about language if it had more reserved keywords.
For example, you may notice that "true", "false", "len", "new", etc all aren't reserved keywords.
This sometimes does lead to bugs, for example someone may make a function, like "func memoize(new func(...interface{}) interface{}) func(...interface{}) interface{}", which shadows a common builtin function with a function argument.
Usually, the above leads to a compiler error when you try to use the "copy" argument (a value) as a function, but every once in a while, you end up with a type-compatible shadow, at which point things can really break.
It would be less confusing if things like "new", "len", "copy", and "true" were keywords, rather than builtins that someone may accidentally alias and shadow.
If you account for things like rather essential builtins as well, go's list of keywords starts to look far less impressive, and on-par with java or C#.