Yes, that's a fair point.

As I was wobbling anyway, I'll give way on that one :)

Alan

On Wednesday, October 17, 2018 at 6:47:25 PM UTC+1, Patrick Smith wrote:
>
> On Wed, Oct 17, 2018 at 3:13 AM alanfo <alan...@gmail.com <javascript:>> 
> wrote:
>
>> On Wednesday, October 17, 2018 at 12:22:15 AM UTC+1, Patrick Smith wrote:
>>>
>>> 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:
>>>
>>
>>  I'm wobbling a bit on disallowing the overloading of the indexation 
>> operator following something Eric said in response to that.
>>
>> However, as long as the proposal includes the ability to overload 
>> conversions as well as operators (another point I made earlier), the 
>> example you gave could be dealt with by implementing a conversion to []int 
>> so you could then use all the latter's properties to code a common function.
>>
>
> If I understand correctly, you would make a copy of the entire list in 
> order to be able to iterate over it? This seems inefficient.
>

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