Indexing access for Lists and Maps considered harmful?

Mark Thornton mthornton at optrak.co.uk
Wed Jun 24 03:08:37 PDT 2009


Ruslan Shevchenko wrote:
> But I steel can't understand: why this is better then:
>
> 1. retrofit interface with names (and semantics), other then put/get
> indexedGetter/ingexedSetter
>
> (I prefer names  #"operator:[]" and #"operator:[]=" )
>
> and semantics for #"operator:[]=" must be return just assigned value,
> not previous.
>   
It is very undesireable to add methods to existing interfaces. But the 
intent of this proposal was to allow indexed access to existing List/Map.

> 2. change '=' semantics to return right part of assignment in case of
> assignment to indexed access.
>   
It is even more undesireable to change existing semantics. Nor is it 
desireable to have the semantics of assignment depend on whether the LHS 
is an index into a list or an index into an array.

Mark Thornton




More information about the coin-dev mailing list