[Java Spec Report] Re: JSR 201 autobox comments
Neal Gafter <[email protected]> Sat, 10 Apr 2004 16:25:47 -0700
| Newsgroups | gmane.comp.java.spec-report |
|---|---|
| Message-ID | <[email protected]> |
Pat LaVarre wrote: > Eh? What provision of the Object.equals() contract breaks if boxed values work like > primitive values? That it be an equivalence relation, i.e. reflexive and transitive. >>>the idea of using new interface types for boxed primitives (as proposed >>>by Gilad Bracha) instead of the wretched legacy wrapper types (Integer, >>>Double, Boolean, etc.). > > > What are the signal virtues of writing a new interface type, rather than a new class type, to > serve as the standard box? Wretchedness of the legacy I understand at least in part e.g. > new Boolean(true) creating yet another != box whose value is true. First, it would be necessary to avoid having the new Double contain data for all the smaller data types (for example). Second, modeling of the primitive subtype relations would require multiple inheritance, which is unavailable in Java. >>new interface types ... >>would also have required deprecating the existing reflection >>APIs and replacing them with another set that uses the new wrapper interfaces, > > > Not sure I wholly appreciate this point. If the existing wrapper classes implemented the > new interfaces, then the existing reflection API could accept the new wrapper interfaces in > place of the existing wrapper classes and everybody ends happy ... no? The existing wrappers can't implement the new interfaces because the contract for equals() on these interfaces wouldn't be satisfied by the existing wrappers, and it would require (for example) Double to implement Comparable<Double> and Comparable<Float> et al, which is not allowed according to the language spec. ------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511 http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/5cFolB/TM ---------------------------------------------------------------------~-> To unsubscribe from this mailing list, send an email to: [email protected] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/java-spec-report/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/