Indexing access for Lists and Maps considered harmful?

Reinier Zwitserloot reinier at zwitserloot.com
Wed Jun 24 18:41:29 PDT 2009


Your general solution does not follow the suggested semantic of  
returning effectively the same value that ends up in the map/list. For  
example, a map that turns any null reference into a marker object  
would pass-through 'null' and not 'MARKER'. It is therefore not a  
consistent solution.

To make your solution fit the bill for any Map or List, the wrapper  
method needs to invoke get(), which isn't acceptable for previously  
stated reasons.

  --Reinier Zwitserloot



On 2009/24/06, at 22:08, Neal Gafter wrote:

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