[e-lang] using @inert with collection APIs

Kevin Reid kpreid at mac.com
Fri Sep 26 16:47:59 CDT 2008


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- at inert variable
>
> and so would:
>
>    @inert Iterator<SomeMutable> i = someKeys.iterator();
>    i.next();    // cannot call non- at 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/>




More information about the e-lang mailing list