5 ms·
Does someone know if there is a good reason why try uses parenthesis? I mean, wouldn't it look even cleaner without them? f := try os.Open(filename)
by arendtio 7y ago
Does someone know if there is a good reason why try uses parenthesis? I mean, wouldn't it look even cleaner without them?
f := try os.Open(filename)
- tptacek 7y agoOne possible reason is that funcall semantics will probably change (Go 2 is likely to have generics), and so simple funcalls keep the language orthogonal; new operators are forever.
- krferriter 7y ago> Go 2 is likely to have generics Big if true. It's one main complication keeping me from adopting Go for more things.
- tptacek 7y agoIt's mentioned in the post we're commenting on.
- ploxiln 7y agoThey did not want to create a new "keyword" that would possibly conflict with some existing variable name. So try() is a built-in function, similar to len(), and if you already have a variable named "try" (or "len") then it shadows the built-in (takes priority in that scope).
- undecidabot 7y agoIt's mentioned in the design doc under "Properties of the proposed design": https://go.googlesource.com/proposal/+/master/design/32437-try-builtin.md#properties-of-the-proposed-design https://go.googlesource.com/proposal/+/master/design/32437-t...