Except for #58, the issues listed below do not describe what are the proposals or are still subject to discussion. I think it is too early for vote! First, is there any discussion on those topics? On my side I have:
Martin
--
You received this message because you are subscribed to the Google Groups "Units Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to units-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to units-dev+unsubscribe@googlegroups.com.
Le 30/03/2019 à 00:27, Werner Keil a écrit :
The only question in https://github.com/unitsofmeasurement/unit-api/issues/185 is, whether or not the API shall provide this in an implementation-independent manner.
Yes, but my point is that if the method has no visible effect on any method accessible through the public API, then it is still implementation-specific even if a method signature appears in the Unit interface. The whole 185 issue is about trying to define an implementation-independent contract for Unit.mix(Unit), and up to now we still have none.
Martin
interface Unit<Q> {MixedUnit<Q> with(Unit<Q>); // Sorry I really don't like the name 'mix'}
interface MixedUnit<Q> extends Unit<Q> {List<Unit<Q>> subUnits();}
--
You received this message because you are subscribed to the Google Groups "Units Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to units-dev+...@googlegroups.com.
Le 30/03/2019 à 11:44, Jean-Marie Dautelle a écrit :
There could be one API contract at the Unit level:
interface Unit<Q> {MixedUnit<Q> with(Unit<Q>); // Sorry I really don't like the name 'mix'}
and one for MixedUnit
interface MixedUnit<Q> extends Unit<Q> {List<Unit<Q>> subUnits();}
Thanks Jean-Marie. But an API contract also needs Javadoc detailing the effect of those methods. The following questions are part of the contract in my opinion, and need answers:
What is the result of converting a value in a unit to a mixed unit (or conversely)? For example what is the result of the following:
FOOT.getConverterTo(FOOT.mix(INCH)).convert(2.5);
What is the result of the following?
FOOT.mix(INCH).getSymbol();
Is the following valid?
INCH.min(FOOT);
What is the difference (except formatting) between the following:
Thanks
Martin
interface CompositeUnit<Q> extends Unit<Q> {Unit<Q> mainUnit();Unit<Q> subUnit();}
interface Unit<Q> {...CompositeConverter<Q> getConverterTo(CompositeUnit<Q>);}interface CompositeConverter<Q> {...long[] convert(double value);}
Personally, I prefer the second choice.FOOT.getConverterTo(FOOT.mix(INCH)).convert(2.5); // Returns [2, 6]
Hello Jean-Marie
Le 30/03/2019 à 15:07, Jean-Marie Dautelle a écrit :
I believe there are two choices:
- A composite unit (a better name I think) has the same behaviour as its main unit (only useful in formatting/parsing).
- A composite unit works not only on numbers but also on tuples (a single number is a tuple of dimension one => same behavior as case 1.0 except that there is truncation to integer values) (…snip…) In others words:
FOOT.getConverterTo(FOOT.mix(INCH)).convert(2.5); // Returns [2, 6]
So do we agree about the following?
Next question. In the case of choice #2, what is the additional measurement information (leaving formatting information apart) in the [2, 6] tuple compared to a 2.5 value that can be decomposed on-the-fly as below?
double value = 2.5; double feet = Math.floor(value); double inch = (value - feet) * 12;
Martin