On Thu, Sep 6, 2018 at 12:49 AM, Christophe Meessen
<christophe.mees...@gmail.com> wrote:
>
> I know about the problems it raised with C++, but Go is different. Go2 draft
> restricts generic parameters to types.
> The only case where there might eventually be an ambiguity is with
> specialized functions in expressions.
>
> I would like to determine if it's still possible to use < > and avoid the
> pitfalls.
>
> One of the option to consider is to use a special character to signal the
> specializing of a generic. Such a special character could be $ for instance.
>
> A generic type or function would be instantiated by the following expression
> :
>
> foo$<int>(...)
> bar$<int,float>(...)
> foo2$<List$<float>>(...)
>
> When there is only one generic parameter, we could use a concise form
>
> foo$int(...) == foo$<int>(...)
> foo2$List$float(...) == foo2$<List$<float>>(...)
>
> My current understanding is that the $ would remove ambiguity in parsing.


Thanks.  I agree that that your suggestion work.  It just boils down
to aesthetic preference.


> The reason I would prefer to use < > is to
> - satisfy to rule of least surprise.

Your suggested syntax is not the same as any existing language I know
of, so I don't think it's reasonable to claim that it is unsurprising.

> - readability

One of the goals of Go is to look light on the page.  Personally I
don't think scattering $ around the code looks good.  I think it is
less readable.  But, as I say, this is an aesthetic preference.  If
there is a consensus in favor of your syntax, or some other
unambiguous syntax, I'm OK with that.

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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to