Skip to main content

Re: Remove "generic" multiply/divide operations from Quantity

  • From: Martin Desruisseaux < >
  • To:
  • Subject: Re: Remove "generic" multiply/divide operations from Quantity
  • Date: Mon, 20 Oct 2014 02:07:20 +0900
  • Organization: Geomatys

Le 20/10/14 01:34, Werner Keil a écrit :
> Users, e.g. those from hig profile Eclipse IoT projects could tell us,
> if being forced to cast would make them abandon the JSR for another
> alternative (well I did not ask them about abandoning, but if cast was
> annoying or show stopper for their needs;-) 
UNITSOFMEASUREMENT-62 is unacceptable, and the fact that Eclipse IoT
like to cast or not will never change anything to that. Neither you or
me or anyone else in this group can have any word on that. It is
unacceptable, period. You can propose other alternatives, like removing
parameterized type completely from the whole JSR-363 project (the pros
and cons would have to be weighted), but not apply UNITSOFMEASUREMENT-62.

> There was never anything that could prevent users of the API from
> doing "stupid" things like:
> Quantity<Energy> speed = (Quantity<Energy) distance.divide(time);
>
But they get a warning! I repeated that many, many times!!! By contrast,
UNITSOFMEASUREMENT-62 wrongly shutdown all warnings - it causes the Java
parameter type system to lie. Furthermore - repeating myself again and
again - we should encourage (not force) the user to cast to (Energy)
instead of (Quantity<Energy>) when he can. The former is safe, the later
is not. This is the same approach than casting Comparable<?> or Enum<?>
to their specific subclasses. E.g. casting an Enum<?> to
(Enum<LinkOption>) is unsafe, while casting to (LinkOption) is safe.

> With Otavio's suggestion the "stupid" declaration would be restricted
> to the left side of the operation instead of doing it twice. A bit
> like Diamond knowing the type from the left side;-)
>
No it is not like the diamond operator. The diamond operation is applied
when the compiler is able to prove that the inferred type is correct.
This is not an "accept any crap the user is putting there" operator!

> Let's see, if JDK guys (or potential users) see a major problem with
> the existing signatures*.*
If by "existing" you mean the UNITSOFMEASUREMENT-62 ones, of course they
will see a major problem!

> Users (especially from IoT) were clear, they won't accept an artificial
> multiply(Argument<?>, Class<?>) option.
>
I do not support a multiply(Argument<?>, Class<?>) method neither. I
mention it only because such method (even if I do not like it) is on the
list of possibilities that the JSR-363 group can choose, together with
accepting the Unit<?> and Quantity<?> return types (my preferred
choice), removing all parameterized types, removing all operations
except add and subtract, etc. But UNITSOFMEASUREMENT-62 is *not* on the
list of things we can choose.

    Martin



Re: Remove "generic" multiply/divide operations from Quantity

(continued)

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/18/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/18/2014

Re: Remove "generic" multiply/divide operations from Quantity

Otávio Gonçalves de Santana 10/18/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Jean-Marie Dautelle 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Martin Desruisseaux 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Werner Keil 10/19/2014

Re: Remove "generic" multiply/divide operations from Quantity

Otávio Gonçalves de Santana 10/17/2014
 
 
Close
loading
Please Confirm
Close