From dougo@ccs.neu.edu Fri Sep 5 14:29:16 1997 Date: Fri, 5 Sep 1997 14:28:58 -0400 Message-Id: <199709051828.OAA00322@vega.neu.edu> From: Doug Orleans To: "Joshua C. Marshall" cc: dem@carbon.ccs.neu.edu Subject: Re: cd *extends* Joshua C. Marshall writes: > Again, should the following work, or am i doing something wrong? :P > > :::::::::::::: > program.beh > :::::::::::::: > Main { > (@ > public static void main(String[] args) throws ParseError { > A a = A.parse("c"); > } > @) > } > :::::::::::::: > program.cd > :::::::::::::: > A = ["c" C] ["d" D] . > B = . > C = *extends* B . > D = *extends* B . > > Main = . > > > Subclasses redefine parse() with a different return val. Yep. Um, I dunno what to do about this. This is why I don't generate parse methods on alternation classes. I guess I could put the name of the class in the name of the parse method, but that seems kind of tedious. Or I could have all parse methods return Object, and the caller would have to cast it to the right thing. This is probably a reasonable compromise, since it's how you have to retrieve things from Vectors and Hashtables etc. Comments? Other ideas? Too bad Java doesn't have contravariant subtyping of functions... --Doug