On Thu, Aug 6, 2020 at 12:11 PM Axel Wagner
<axel.wagner...@googlemail.com> wrote:
>
> On Thu, Aug 6, 2020 at 8:53 PM Ian Lance Taylor <i...@golang.org> wrote:
>>
>> My point wasn't that a string is a number.  My point was that the
>> current design draft permits writing a function that uses + and works
>> with both strings and numbers.
>
>
> Is there a need for that? I can't really imagine one.

Probably not.  But every exception is in itself a piece of complexity
that people have to learn.  As a general guideline, the fewer
exceptions, the better.


> That being said, in general I agree with you that type-lists allow you to be 
> more deliberate about the semantics of the operators.
> I would actually come from the other direction and say that both `string` and 
> `int` have `+`, but both have clearly different meanings. And even `uint`, 
> `int` and `float64` have subtle differences in how `+` works (for example: 
> `float64` can have `a+b==a && b != 0`).
> So, given that `+` has different meanings for different types, listing them 
> explicitly gives more control over the behavior you intend.

Makes sense.  Thanks.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcV18H4i4Cr1ey0rv1KwhpvAErrkTovZ7Nm7tafkp1qXWA%40mail.gmail.com.

Reply via email to