Re: using @inert with collection APIs
Kevin Reid <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
On Sep 24, 2008, at 16:45, Tyler Close wrote: > 1. We were unable to use the standard iteration API, since it uses a > mutable iterator object. So the following code would generate a > verifier error: > > Iterator<SomeMutable> i = someKeys.iterator(); // cannot hold > return value in non-@inert variable > > and so would: > > @inert Iterator<SomeMutable> i = someKeys.iterator(); > i.next(); // cannot call non-@inert method on @inert reference. It seems to me that what you want to express here is Iterator<@inert SomeMutable> i = someKeys.iterator(); Whether something equivalent to this is possible in Java I don't know. > ... If not, this also means we need to make the ConstArray.with() > implementation efficient enough for this task. If we do so, we might > as well deprecate the ArrayBuilder interface. In case the example is useful, I'd like to point out that E-on-CL already implements the O(n^2)->O(n) 'with' optimization for arrays and maps. The relevant code is in svn://www.slimy.com/cl-e/cl-e/trunk/lisp/elib-values.lisp svn://www.slimy.com/cl-e/cl-e/trunk/lisp/tables2.lisp svn://www.slimy.com/cl-e/cl-e/trunk/lisp/lazy.lisp ; search for "with-node" in the first two. -- Kevin Reid <http://homepage.mac.com/kpreid/>