[e-lang] Generators for the other Joe-E array types

Adrian Mettler amettler at cs.berkeley.edu
Wed Dec 19 18:01:59 EST 2007


This all looks good so far; I'll put out a version of the library that 
includes this after Christmas, along with the runtime taming stuff.  The 
new version of the verifier that includes this is making progress and 
should be released in early January (it won't quite be ready before the 
holidays).
-Adrian

David Wagner wrote:
> Tyler Close writes:
>> I think we need generators, like the recently discussed
>> ByteArray.Generator class, for all the other Joe-E array types as
>> well.
> 
> This sounds good to me.  Adrian, what do you think?  Are you okay
> with this?
> 
>> I think we need something like:
>>
>>    interface Generator<T> {
>>        void append(T value);
>>        ConstArray<T> snapshot();
>>    }
> 
> You mentioned that you wanted to eliminate all unsafe casts.  The
> interface above may require casting the return value of snapshot()
> to the appropriate subtype of ConstArray.  For example, consider the
> following usage:
>     Generator<T> g = PowerlessArray.generate(n);
>     ...
>     PowerlessArray<T> a = (PowerlessArray<T>) g.snapshot();
> The last line requires an unchecked cast.  Is that okay?  Would you
> prefer to have the interface be designed to be statically type-safe?
> 
> For example, would the following alternative be better?
>     interface Generator<A extends ConstArray<T>,T> {
>         void append(T value);
>         A snapshot();
>     }
> Each Joe-E array type would provide a generate() method that returns
> the appropriate type; e.g., PowerlessArray<T>.generate()'s return type
> would be Generator<PowerlessArray<T>,T>.  That would eliminate the
> need to cast the return value of Generator.snapshot() to the appropriate
> array type.  Does this seem like an improvement?
> _______________________________________________
> e-lang mailing list
> e-lang at mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang



More information about the e-lang mailing list