Indexing access for Lists and Maps considered harmful?

Ruslan Shevchenko rssh at gradsoft.com.ua
Wed Jun 24 08:37:46 PDT 2009


> On Wed, Jun 24, 2009 at 1:02 PM, Reinier Zwitserloot <
> reinier at zwitserloot.com> wrote:
>
>> That isn't a retrofit; existing implementations simply do not work
>> unless
>> you statically import a newly written method.
>>
>
> Exactly: programmers opt-in to this form.
>

Or compiler can use Collections.operator_set_index(), when desugaring
operator[] in compound assignment, where first operator is index over 
List or Map.

(It is possible to look on this as 'extension methods at compile-time').

(it's variant #6, which can be practically usable).

>
>> trying to write a generic form of such a method would have to build it
>> from
>> the put and get primitives, which puts you in the same boat: needless
>> and
>> expected get calls in 99% of all assignments. So, no, you haven't shown
>> this.
>>
>
> I don't see a needless get call in the implementation I provided.  Do you?
>
>





More information about the coin-dev mailing list