Record construction
Stephen Colebourne
scolebourne at joda.org
Thu Mar 15 08:32:57 UTC 2018
On 14 March 2018 at 22:09, Brian Goetz <brian.goetz at oracle.com> wrote:
>> Minor tweak, but class names can get quite long. A keyword would be
>> preferable:
>
>
> Yes, that's also a realistic option, and reminiscent of instance
> initializers (but has the advantage of _not_ being an instance initializer,
> which already means something.) From a readability perspective, I have a
> subjective preference for something that looks like a constructor, but I'd
> not rule this out. (Remember, reading code is more important than writing
> code, so I don't think the length of the name is really the primary
> consideration.)
In my experience reading code, constructors tend to blend into method
too easily. A keyword (that is usually highlighted in a different
colour) would make the initializer read as being more clearly
different to methods.
>> Wild idea - is there a way for the library method to obtain the
>> variable name and type used at the call site?:
>
> Putting it in terms of a variable name and type doesn't make sense, because
> there might be multiple variable names and types:
>
> Preconditions.require(x < y);
>
> Doing so would require something like expression trees, a major project.
I wasn't thinking of that. Just something that can provide the
expression as a sting. I think Remi captured it in his response.
Its not an essential thing, but the repetition without it is a factor
in judging the merits of a `requires` keyword..
Stephen
More information about the amber-dev
mailing list