Why not make the curly brackets on interface{} optional, and make the formatter remove them?
This would be consistent with how semicolons are treated.
Also as opposed to a ;, interface{} could be used in the middle of a
line e.g. func foo(bar interface{} ... and thus the rewrite rules
would become considerably more complicated than 'append semicolons to
ends of lines'. What makes that optional is that it is done for you.
Also consider:-
fn := func() interface {
// Some code
}
There'd be an ambiguity between our optional {}'d interface + the code
in the closure.
--
Lorenzo Stoakes
http://www.codegrunt.co.uk
Considering what you wrote, perhaps the curly braces could be made optional where there is no ambiguity.
Yes. Related to this, code is prose, or at least it could be. Most
style rules for writing prose can be applied to code, at least in some
equivalent form.
Write-only languages like APL are fun, in the same way linguistic
riddles are fun, but when you write newspaper articles you use a
different style (or at least newspapers used to do so).
--
Aram Hăvărneanu
Quite. A lot of the appeal of go is the taste and restraint of the
language - features really have to carry their weight :)
This is still ambiguous - does it return interface{} (in this
scenario, 'interface') or interface { doSomething() }?
Just my 2 pence :)
在 2011-12-30 下午9:31,"Starfish" <ahn...@rocketmail.com>写道:
>
> Or maybe,
> func f(arg interface) int { ... }
How about uses a new keyword "anytype" (or variant) ? And we can write:
func f(arg anytype) int { … }