On Tue, Jun 16, 2020 at 9:02 PM Xie Zhenye <[email protected]> wrote:
>
> In the draft, it says:
> "Why not use the syntax F<T> like C++ and Java?
> When parsing code within a function, such as v := F<T>, at the point of 
> seeing the < it's ambiguous whether we are seeing a type instantiation or an 
> expression using the < operator. Resolving that requires effectively 
> unbounded lookahead. In general we strive to keep the Go parser efficient."
>
> Maybe adding type metadata to an identifier during parsing, and using the 
> metadata of an identifier may resolve the ambiguous of type parameter or less 
> operator.   For example, '<' after a variable or constant name is a less 
> operator and '<' after a function or type name is a type parameter.
>
> <> will be more readable than () and easier to identify type parameter and 
> function call.

Let's try using this syntax for a while before we discard it.  Thanks.

That said, it's a key feature of Go that it is possible to parse a
program without requiring any type information.  That is how tools
like gofmt work.  We must be able to parse Go code without building a
symbol table.  So the suggestion of adding type metadata to an
identifier during parsing is not a choice we are going to take.
Thanks for thinking of it, though.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWnL03zdDAHMNt4Lx3OxefKTxfLxs27YCCyqnQMvCmCrg%40mail.gmail.com.

Reply via email to