Re: [go-nuts] Silly question about parentheses

2023-02-01 Thread David Finkel
On Wed, Feb 1, 2023 at 11:22 AM Chris Burkert wrote: > Looking into the spec: > > https://go.dev/ref/spec#Return_statements > ReturnStmt = "return" [ ExpressionList ] . > ExpressionList = Expression { "," Expression } . > ... no () here > > https://go.dev/ref/spec#Function_types > FunctionType

Re: [go-nuts] Silly question about parentheses

2023-02-01 Thread Chris Burkert
Looking into the spec: https://go.dev/ref/spec#Return_statements ReturnStmt = "return" [ ExpressionList ] . ExpressionList = Expression { "," Expression } . ... no () here https://go.dev/ref/spec#Function_types FunctionType = "func" Signature . Signature = Parameters [ Result ] . Result

Re: [go-nuts] Silly question about parentheses

2023-02-01 Thread Raphael Clancy
This is really helpful! Thank you! At first I assumed that it was down to 'go fmt' letting you be fairly loose with your syntax and that you could omit parentheses where the meaning wouldn't be ambiguous. But on closer examination, there must be something else going on because 'return a, b' wo

Re: [go-nuts] Silly question about parentheses

2023-02-01 Thread 'Axel Wagner' via golang-nuts
Good point, didn't think of that On Wed, Feb 1, 2023, 15:30 p...@morth.org wrote: > It would actually be ambiguous in the very place they're required. > > Consider this not completely unreasonable example: > https://go.dev/play/p/OL0uOnPZXju > > Also, with generics it could be ambiguous in type

Re: [go-nuts] Silly question about parentheses

2023-02-01 Thread p...@morth.org
It would actually be ambiguous in the very place they're required. Consider this not completely unreasonable example: https://go.dev/play/p/OL0uOnPZXju Also, with generics it could be ambiguous in type parameters. To summarize, parentheses are needed around the return types because otherwise an

Re: [go-nuts] Silly question about parentheses

2023-01-31 Thread 'Axel Wagner' via golang-nuts
I'm not sure there really is a "reason", per se. The language could just as well have been designed not to require parentheses around the return types (at least I see no parsing ambiguity with that, though there might be) or designed to require parentheses in the return statement. It probably just

[go-nuts] Silly question about parentheses

2023-01-31 Thread Raphael Clancy
Hey all, I figured it was time to move to a "modern" language and I thought I'd give go a try. So far, I'm really enjoying it. I'm just getting started and I had a question about parentheses. Though, I guess it's really about how go parses lines of code and what counts as a delimiter. Anyway, i