Indexing access for Lists and Maps considered harmful?

Rémi Forax forax at univ-mlv.fr
Wed Jun 24 02:57:47 PDT 2009


Neal Gafter a écrit :

[...]
> My favorite solution is a combination of specification by
> syntactic translation and the addition of support for extension methods.  It
> can be retrofitted onto any existing class or interface without breaking
> backward compatibility, and can be defined to have precisely the necessary
> semantics to match the JLS specification for assignment.
>   

I think we can split the problm in two: at call site and a declaration site.
At call site as you said, we need a syntactic translation to be conform 
with rules
of the JLS about assignments.
At declaration site, you want use extension methods, I'm not a big fan 
of them,
because they don't obey to the late binding mechanism.
Furthermore, I don't think kthey are needed here, a simple keyword is 
sufficient.
Let's call it "indexer"

public interface List<E> {
   indexer public E get(int index);
}

public class MyIntList {
  indexer public void set(int index, int value) { ... }
}

There is just a small problem, coin doesn't allow new keyword ...

We will need extension methods if we want closures, but
we will see later.

>
>   
>> NB: I'd hereby like to repeat my suggestion to choose pragmatism over
>> perfection here:
>>     
>
>
> Sure, if there were a conflict between the two (there isn't) that would be
> reasonable.  Adding direct support for the collection interfaces to the JLS
> isn't a reasonable approach either.
>
> Cheers,
> Neal
>
>   
Cheers,
Rémi



More information about the coin-dev mailing list