Re: Joe-E

[email protected] (David Wagner)
Newsgroups gmane.comp.lang.e.general
Organization University of California, Berkeley
Message-ID <[email protected]>
Steven R. Brandt wrote:
> After a little thought, I believe I have an acceptable solution for the 
> problem. In case it is of use, here's what I did to implement a 
> powerless list class:
> 
> public class PowerlessList<T> {

Did you mean to add "implements Powerless"?

Why not use org.joe_e.array.PowerlessArray?  If you want an ordered
sequence of Powerless items, it seems to be exactly what you want:
PowerlessArray is a Powerless, ordered sequence of Powerless items.  As a
bonus, it provides more efficient random access to elements than your
PowerlessList, and the PowerlessArray has a number of utility methods.
And, most importantly, PowerlessArray cleanly handles the issue you
mentioned (it can hold classes explicitly declared Powerless; it can
also handle legacy classes that are honorarily Powerless, like String).

> The key is the holder class. It is able to hold a String, Integer, etc. 
> Essentially, it turns the check from a compile-time to a run-time check, 
> and allows me to use either String or Powerless. Of course, the whole 
> thing might die with a bad type error, so it's a trade-off.

I noticed your implementation hardcodes String, Number, Boolean, and
Character, so it may miss other classes that are honorarily powerless.

Should we add an ImmutableHolder and a PowerlessHolder to the Joe-E
library, written along the lines of the ImmutableArray and PowerlessArray
implementation?  If so, do you want to propose some code?

> The basic problem, I think, is that Powerless is a marker interface. If 
> it were an attribute instead, then I think things would be nicer.

Hmm.  I haven't thought about this, but I'm guessing one challenge
is that this would require re-implementing Java's type checks, so it
might take more work.

> Maybe you could consider this for a future version?

Unfortunately we have no current plans, and no resources, to make major
changes to Joe-E.  We're not actively developing Joe-E at this point;
it's a research project, and we've currently moved on to other projects.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.