Default value for date/time

Stephen Colebourne scolebourne at joda.org
Wed May 9 07:01:06 UTC 2018


On 9 May 2018 at 01:59, Brian Goetz <brian.goetz at oracle.com> wrote:
>>
>> Whats the default Currency? USD is a not an acceptable answer. Money
>> is the same as it can't exist without a currency.
>
> This is the point we’ve been trying to make.  Some types (like Complex) have a natural default (zero), others do not.  So the VM provides a uniform treatment — and then the class can be coded to interpret the default value whichever way makes sense for the domain.  If Complex has a natural zero, then you need not do anything special.  If Currency has no natural default, then a Currency whose bit pattern is the default bit pattern should be coded so its methods throw.

I see how this is a rational point in the JVM design space, just
remarking that I don't think its a particularly attractive one at the
coder's level from what I've seen so far (but its early, things can
change).


On 9 May 2018 at 01:53, Gil Tene <gil at azul.com> wrote:
> Perhaps “works like a double” is a better analogy? Doubles have NaNs. Dates can have NaDs.

Yes, a better analogy, though not perfect.


On 9 May 2018 at 01:47, John Rose <john.r.rose at oracle.com> wrote:
>> Whats the default Currency? USD is a not an acceptable answer. Money
>> is the same as it can't exist without a currency.
>>
>> What about a Distance object? Is it measured in Miles or Kilometers by default?
>
> Thanks, I get it now.

FWIW having slept on it, if Currency had to have a default, it could
be XXX, which means "no currency".

> You are asking for a certain kind of
> mashup between objects and primitives, which is understandable,

I'm trying to not ask for something specific given I don't appreciate
all the trade offs. Instead, I'm trying to express feelings/reactions
which may or may not help guide you :-)

thanks
Stephen



More information about the valhalla-dev mailing list