Use Advanced Search to search the entire archive.
Re: Remove "generic" multiply/divide operations from Quantity
- From: Werner Keil <
>
- To:
- Subject: Re: Remove "generic" multiply/divide operations from Quantity
- Date: Sun, 19 Oct 2014 18:43:50 +0200
times() would not even compile;-)
We changed it on Josh's demand. And so far with JSR 354 also sticking to a
BigDecimal like syntax, I don't see why we should change that.
JSR 310 picked a weird mix between sligtly renamed BigDecimal like methods
and a few taken either from an earlier version of 275(*GG* not the only
"inspiration") Scala or Groovy. It's an "Odd Fellow" in many ways, so
probably better to stick with naming other JSRs or parts of the JDK
follow;-)
Werner
Am 19.10.2014 18:19 schrieb "Jean-Marie Dautelle"
<
>:
>
Hello All,
>
>
Unit<?> is better than Unit without parameterized type. Also the second
>
issues warnings about the use of raw types.
>
Unit<?> makes a lot of sense in many cases, for example when we don't know
>
the unit type as: Unit<?> parseUnit(CharSequence)
>
The method Unit<Q> asType(Class<Q extends Quantity>) allows for proper
>
casting* with* runtime checking being performed. In other words you can
>
safely write:
>
Unit<Velocity> km_per_hour =
>
KILO(METER).divide(HOUR).asType(Velocity.class); // Safe.
>
Unit<Velocity> km_per_hour =
>
KILO(METER).times(HOUR).asType(Velocity.class); // Throws runtime error.
>
Unit<?> km_per_hour = KILO(METER).times(HOUR); // If I don't care
>
about unit types.
>
>
I don't understand the issue with JDK8 since all of the above works well
>
with JDK1.5+
>
Cheers,
>
JM
>
>
>
On Sun, Oct 19, 2014 at 5:15 PM, Martin Desruisseaux <
>
>
>
wrote:
>
>
> Le 20/10/14 00:09, Werner Keil a écrit :
>
> >
>
> > It however looks like especially the Output of Unit<?> is going to
>
> > cause us trouble in JDK8+ ;-/
>
> >
>
> This question should be over for a long time: there is no other possible
>
> output for multiply/divide/inverse/pow operations, no matter how we turn
>
> the problem, except if we provide a Class argument.
>
>
>
> I'm in the process right now to write an email to the OpenJDK mailing
>
> list for making that clear. But I will submit it to this list before to
>
> send it - I will not send it without authorisation.
>
>
>
>
>
> > The reflect() method of ReflectionDemo won't compile with Unit<?>
>
> > either for input parameters coming from at least a "chain" of
>
> > wildcards like Unit.multiply(Unit<?>).asType() which again throws out
>
> > Unit<?>.
>
> >
>
> I will look at that tomorrow.
>
>
>
>
>
> Martin
>
>
>
>
>
>
>
--
>
It is not the strongest of the species that survives, nor the most
>
intelligent. It is the one that is most adaptable to change. - Darwin's
>
Origin of Species (digest)
>