On Tue, Oct 16, 2018 at 5:44 PM robert engels <reng...@ix.netcom.com> wrote:

> The easiest solution is that []int IS A IntList by definition, no ?
> Meaning that an “slice” has defined methods Len(), and At(). I would
> personally define other methods on slice too for convenience (like, Insert,
> Delete). The [] notation is just syntactic sugar for slice.At(). When used
> as a left side, it is syntactic sugar for Set().
>
> On Oct 16, 2018, at 6:21 PM, Patrick Smith <pat42sm...@gmail.com> wrote:
>
> On Tue, Oct 16, 2018 at 3:33 AM alanfo <alan.f...@gmail.com> wrote:
>
>> I would also disallow overloading of the =, :=, <-, ..., [], {}, () and
>> yes - equality operators - as well because I believe to do otherwise would
>> be very confusing.
>>
>
> If overloading [] were disallowed, how would one write a generic function
> taking a single argument of type either []int or a user-defined type with
> similar behavior, and returning the sum of the elements? Sort of the
> marriage of these two functions:
>
>
Sorry if I was unclear. I wanted to know, not how it could be done under
some other proposal (such as adding methods to built-in types), but how
Alan or Eric would do it in their proposals for operator overloading.

-- 
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