News for hackers. Stuff that matters.
Re:Go 1.21 by WhereIsTheTruth on Wednesday June 21, 2023 @05:15PM (#36424658)
> 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

Re:Go 1.21 by pjmlp on Wednesday June 21, 2023 @05:42PM (#36425054)
For anyone that misses their Objective-C days.
Re:Go 1.21 by philosopher1234 on Wednesday June 21, 2023 @05:18PM (#36424716)
They're not reserved keywords. Existing/package defined min/max functions would take precedence. They have the same semantics as `append`
Re:Go 1.21 by WhereIsTheTruth on Wednesday June 21, 2023 @05:23PM (#36424800)
You 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..

Re:Go 1.21 by vito on Wednesday June 21, 2023 @05:45PM (#36425088)
The 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?
Re:Go 1.21 by KRAKRISMOTT on Wednesday June 21, 2023 @05:54PM (#36425187)
A heap?
Re:Go 1.21 by bananapub on Wednesday June 21, 2023 @05:44PM (#36425078)
if you have so few tests and so little code review that this matters then I am not sure what to suggest
Re:Go 1.21 by Chiron1991 on Wednesday June 21, 2023 @05:47PM (#36425104)
Not too familiar with go toolchains, but I bet there's a linter that will warn you about shadowing builtins.
Re:Go 1.21 by Mawr on Wednesday June 21, 2023 @11:38PM (#36427752)
Yep: "variable append has same name as predeclared identifier (predeclared) go-golangci-lint"
Re:Go 1.21 by dgfitz on Wednesday June 21, 2023 @05:54PM (#36425186)
Qt uses qMin and qMax, it may have been nice if go went with like gMin and gMax
Re:Go 1.21 by throwawaygo on Wednesday June 21, 2023 @05:57PM (#36425222)
breaks all my variables named min and max
Re:Go 1.21 by garfij on Thursday June 22, 2023 @02:27PM (#36436591)
Re:Go 1.21 by Dudester230602 on Wednesday June 21, 2023 @06:05PM (#36425322)
They did not expect a simple language created for faster onboarding of graduates to catch on. Now that community is pushing for features the language might evolve in strange ways...
Re:Go 1.21 by BarkMore on Wednesday June 21, 2023 @06:14PM (#36425419)
min and max are predeclared identifiers in the universe block, not reserved words. https://go.dev/ref/spec#Predeclared_identifiers

You can continue to declare your own entities with these names.