You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Mark R. Diggory" <md...@latte.harvard.edu> on 2003/07/03 21:32:00 UTC

[math] Generics was: Re: [math] abstact nonsense was ...

Craig R. McClanahan wrote:

>On Thu, 3 Jul 2003, Al Chou wrote:
>
>  
>
>>Date: Thu, 3 Jul 2003 12:05:49 -0700 (PDT)
>>From: Al Chou <ho...@yahoo.com>
>>Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
>>To: Jakarta Commons Developers List <co...@jakarta.apache.org>
>>Subject: Re: [math] abstact nonsense was Re: [math][functor] More Design
>>    Concerns
>>
>>--- "Mark R. Diggory" <md...@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
>  
>
>>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
>
>  
>
That auto-boxing capability alone would make me jump for joy!
JavaOne: a very worthwhile subscription I can get my employer to cover ;-)

-Mark


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