A{I: 1}.Print()
prog.go:23: cannot call pointer method on A literal
As an exception to the addressability requirement, x
may also be a (possibly parenthesized) composite literal.
Le 25 juin 2013 06:47, "David DENG" <david...@gmail.com> a écrit :
>
> It seems the specs does not define the precedence of the address operaton. If given that, there should be no ambiguities. &(A{...}.Something()) is illegal in current compiler. so not the ambiguity problem.
>
It's not about ambiguity, in your expression there is a single operator '&'. the dot is not an operator.
> And my question is A{...}.Something() does not has ambiguities, why not allow?
>
The goal of the language is not to define the scope of what it can guess you wanted to write.
Adding exceptions to the rules adds more special cases to the specification, which complicates the language instead of simplifying it.
Rémy
i := &Int(0)