Proposal: Indexing access syntax for Lists and Maps
Schulz, Stefan
schulz at e-Spirit.de
Mon Mar 30 23:03:59 PDT 2009
Stephen Colebourne wrote:
> I'm surprised annotation solutions are being considered given the
> general approach taken to annotations affecting the language.
I actually had the same question in mind. In various places (and reactions on proposals on this list), annotations are doomed for influencing the outcome of the compilation process (e.g., ARM). Why should index access be different?
> IndexedGet
> IndexedSet
> MappedGet
> MappedPut
I much prefer this approach, especially as one can only implement them once (annotations would require additional checks on multiple use). It might require some strategy, though, when a class implements both, indexed and mapped get.
> It might be a good time to retrofit a Sized interface too,
> defining the
> size() method.
Hm. Would it make sense to have something like Contains and ContainsKey, too?
> Finally, arrays must "implement" the new indexed interfaces. This is
> critical to allow code like this to work:
This is interesting and fits into the development of unifying access to collections and arrays very well.
Stefan
More information about the coin-dev
mailing list