[e-lang] Generators for the other Joe-E array types
Tyler Close
tyler.close at gmail.com
Fri Dec 28 11:39:08 EST 2007
Hi Adrian,
When you code this up, you might want to use the term "Builder"
instead of "Generator" so as to follow the convention set by
java.lang.StringBuilder.
--Tyler
On Dec 19, 2007 3:01 PM, Adrian Mettler <amettler at cs.berkeley.edu> wrote:
> 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
>
> _______________________________________________
> e-lang mailing list
> e-lang at mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang
>
--
Use web-keys for RESTful access-control:
http://waterken.sourceforge.net/
Name your trusted sites to distinguish them from phishing sites.
https://addons.mozilla.org/firefox/957/
More information about the e-lang
mailing list