commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [math] abstact nonsense was Re: [math][functor] More Design Concerns
Date Thu, 03 Jul 2003 19:19:41 GMT


On Thu, 3 Jul 2003, Al Chou wrote:

> Date: Thu, 3 Jul 2003 12:05:49 -0700 (PDT)
> From: Al Chou <hotfusionman@yahoo.com>
> Reply-To: Jakarta Commons Developers List <commons-dev@jakarta.apache.org>
> To: Jakarta Commons Developers List <commons-dev@jakarta.apache.org>
> Subject: Re: [math] abstact nonsense was Re: [math][functor] More Design
>     Concerns
>
> --- "Mark R. Diggory" <mdiggory@latte.harvard.edu> wrote:
> > Anton Tagunov wrote:
> > > 3)
> > >
> > > BTW, probably does the future introduction of Generics (Java 1.5)
> > > promise any opportunities to work with primitive values and yet
> > > have no code duplication (a bit like STL)?
> > >
> >
> > I've not spent much time looking at Generics yet. I have allot to learn
> > in this area.
>
> I believe for our purposes it suffices to describe generics as the ability to
> write something like (I'm too lazy to look up the exact syntax):
>
> ArrayList<Double> myArray = new ArrayList()<Double> ;
> Double d ;
> int position = 0 ;
>
> myArray.add( new Double( 1.0 ) ) ;
>
> // Here's the part where generics make life easier.  Look, Ma, no cast:
> d = myArray.get( position ) ;
>

My understanding is that this is exactly what you'll get from the
auto-unboxing capability.  The compiler will be able to see that the right
hand side returns a Double, and generate the code to unbox it into a
double primitive for you.

This is separate from Generics because it also works in other scenarios:

  Double d1 = new Double(1.0); // A lowly scalar instance of the wrapper
  double d2 = d1;              // But no cast here either!
  d1 = d2 + 0.5;               // Or here ... it is bidirectional

> Al

>From http://java.sun.com/javaone you can download a webcast of the
Technical General Session on Tuesday morning that covered the 1.5 language
changes, including both of the topics above.  It was the first time I'd
ever seen cheering sections for the different proposed features :-).

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message