There has been a lot of criticism of the presentation from James
Gosling but I found it if fairly good (give or take ASF rather than
ASP).

As regards primitive wrappers the implementation gets more complicated
if you try and have a hierarchy. The existing implementation uses
classes. If these classes extended each other then there would be
redundant internal fields from the parent type, waisting memory. This
might be avoided by storing the internal value as a byte array.

The other approach would for all the number types to be Interfaces.
This would require separate implementation classes increasing
complexity. Also perhaps a static factory could be used to at least
hide the implementation classes, i.e. Numbers.wrap(1);

The Java language spec may allow a float to be a parent of long but I
think this may be a mistake due to the potential for loss of
precision. It may have been better
to have a branch in the hierarchy such that float went to int but not
to long and double to float or long (which in turn goes to int). I am
not a type expert though. I think wherever there could be loss of
precision, implicit conversion is not suitable. For that matter though
a conversion from long to double can loose precision due to the
mandatory bits used for the exponent. Perhaps then long would not come
from double but integer yes (because the mantissa would be big enough
not to loose precision). In the same way float would not go to int but
would go to short for the same reason. Still none of this would be
compatible with the current spec which is as it is.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to