> On Jun 2, 2023, at 2:46 PM, Kevin Bourrillion <[email protected]> wrote: > > This is not too important right now, but I had thoughts, so... > > > On Thu, Jun 1, 2023 at 10:59 AM Brian Goetz <[email protected]> wrote: > > Users should be able to say `new Complex()` and get a default complex value. > (Maybe they can also say `Complex.default`; maybe we won't need that.) And > the same for reflection. > > I think the argument for `MyVal.default` being *unnecessary* might go like > this: > > * either there's no implicit constructor and `MyVal.default` won't work > * or there is, and `MyVal.default` would have to mean the same as `new > MyVal()`, so what's the point? > > If that's correct, there might not be a strong argument for keeping it, but I > came up with a couple weak ones. > > 1. Arguably, its meaning is more apparent without the reader having to dig > into MyVal.java (how much does this matter, in this case?) > 2. It *feels like* a well-known immutable value that just kind of "exists" > and has no need to be constructed. A constant. In fact people might feel > tempted to make such constants?
Another weak one: 3. MyVal.default should be a linkage error (or in some worlds, evaluate to 'null') if a B3 class evolves into a B2 class. 'new MyVal()' should be fully compatible—it's the same API point whether the class is B3 or B2, and the caller using this syntax is unlikely to care about its implementation.
