3 ms·
> New built-in functions: min, max and clear. What a mistake.. reserved keywords are words I can no longer use for myself... Zig does it better by requiring a
by WhereIsTheTruth 3y ago
> New built-in functions: min, max and clear.
What a mistake.. reserved keywords are words I can no longer use for myself...
Zig does it better by requiring a prefix @ for most their builtin needs
- philosopher1234 3y agoThey're not reserved keywords. Existing/package defined min/max functions would take precedence. They have the same semantics as `append`
- WhereIsTheTruth 3y agoYou refactored your code, you think you wrote your ``min`` function, but no, it'll call the builtin one, without warning you.. I don't like this design..
- bananapub 3y agoif you have so few tests and so little code review that this matters then I am not sure what to suggest
- vito 3y agoThe compiler will tell you if the types aren't compatible, and this is only for primitive comparable types. What `min()` implementation could you have that even does something different?
- KRAKRISMOTT 3y agoA heap?
- Chiron1991 3y agoNot too familiar with go toolchains, but I bet there's a linter that will warn you about shadowing builtins.
- Mawr 3y agoYep: "variable append has same name as predeclared identifier (predeclared) go-golangci-lint"
- dgfitz 3y agoQt uses qMin and qMax, it may have been nice if go went with like gMin and gMax
- pjmlp 3y agoFor anyone that misses their Objective-C days.
- throwawaygo 3y agobreaks all my variables named min and max
- garfij 3y agoNot at all https://play.golang.com/p/c5tGTMamjj_a https://play.golang.com/p/c5tGTMamjj_a
- Dudester230602 3y ago[flagged]
- BarkMore 3y agomin and max are predeclared identifiers in the universe block, not reserved words. https://go.dev/ref/spec#Predeclared_identifiers https://go.dev/ref/spec#Predeclared_identifiers You can continue to declare your own entities with these names.