[External] : Re: Proposal: Static/final constructors for bucket-3 primitive classes.

John Rose john.r.rose at oracle.com
Thu Dec 9 18:15:06 UTC 2021


On 9 Dec 2021, at 7:25, forax at univ-mlv.fr wrote:

> We may do something like that in a possible future, but i think it's 
> more important to make the semantics of B3 visible front and center.

If you can only say one thing in such an explicit no-arg constructor 
(true initially and maybe forever) then it surely is strange that the 
silly thing has a body.  So that leads to some un-bodied presentation 
like `class P { public default P(); }`, which could be made more 
expressive later (or never, probably).

But that, in turn, hits near to one of the places where Java *already 
set the default* (rightly or wrongly). Java defines, under some 
circumstances, the no-arg constructor for a class implicitly.  Arguably 
this precedent applies (though not exactly) to the current case, of 
default construction of the default value.

I think, in the end, making a new primitive (as opposed to a new value 
class) is going to be an activity for library experts, not end users.  
Maybe the IDEs (not the JLS) can help them avoid pitfalls, but 
primitives are inherently tricky things to define.  This means either 
that (a) it’s OK to force the experts to do the extra ceremony’s or 
(b) it’s OK to assume they know the rules of that game, and the 
ceremony won’t add anything.  I incline towards (b).

The vision I’m assuming here is that a _bare primitive_ is something 
inherently loosely assembled.  It’s really just a bundle of scalar 
values.  If you want a class wrapped around that bundle, you should be 
declaring your value as a _primitive reference_ (assuming the option for 
the bare primitive must also be provided) or declaring your type as a 
true _value class_ (if the option for the bare primitive is not so 
important).

P.S. A friend kindly helped me update my metaphor firmware.  I meant to 
say that pushing the feature under discussion would lead us along a path 
of pain, with various experiences along the way.  But obviously not 
existential Jacksonian pain.  And that’s all I want to say here about 
that.


More information about the valhalla-spec-observers mailing list