[Biojava-l] Location interface
Forsch, Dan
dorsch@netgenics.com
Mon, 30 Apr 2001 13:19:29 -0400
JSR #14,
http://java.sun.com/aboutJava/communityprocess/jsr/jsr_014_gener.html, will
provide parameterized types like C++ templates that should allow you to do
some of what you want. There still wouldn't be operator overloading but you
could define plus() and minus() methods. I couldn't tell if this one has a
release target yet but I believe I heard it will be in the next major
release (1.4?). I personally am partial to strong typing and polymorphism,
but to each their own.
Dan Forsch, Principal Software Engineer
NetGenics, Inc.
> -----Original Message-----
> From: Matthew Pocock [mailto:mrp@sanger.ac.uk]
> Sent: Monday, April 30, 2001 6:15 AM
> To: 'biojava-l@biojava.org'
> Subject: [Biojava-l] Location interface
>
> The rational behind moving the binary operators is that Java has
> extremely poor support for double-binding, and the current
> code-base is
> ickey.
>
> We realy want to attach operators to tuples, not classes.
> Imagine if we
> could define and use methods on tuples and let the method
> binding work
> out as for the single-binding (inheritance) case. The tuples
> could look
> like arrays with individualy typed indecies. If tuples can implement
> interfaces then one interface could be the 'operator overloadable'
> interface, at which point we get safe overloading of binary operators
> like + and -.
>
> boolean ol = [locA, locB].overlaps();
>
> abstract tuple Location, Locaion {
> abstract boolean overlaps();
> abstract boolean equals();
>
> ...
> }
>
> and provide implementations like this:
>
> tuple RangeLocation, RangeLocation {
> boolean overlaps() {
> return !(this[0].getMin() > this[1].getMax() ||
> this[0].getMax() < this[1].getMin());
> }
>
> ...
> }
>
> tuple RangeLocation, PointLocation {
> boolean overlaps() {
> return this[0].getMin() >= this[1].getMin() &&
> this[0].getMax() <= this[1].getMin();
> }
>
> ...
> }
>
> _______________________________________________
> Biojava-l mailing list - Biojava-l@biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
>