PROPOSAL: Auto-assignment Parameters
Mark Mahieu
markmahieu at googlemail.com
Wed Mar 25 10:33:51 PDT 2009
Hi James,
I looked into inferring the parameter types, and while it does work
quite well for 'brain-dead' POJO classes, it was not so great when
you actually want to put some real code in the constructor, for
example to throw an exception if a parameter value is not valid.
The auto-assignment proposal is very much aimed at helping
programmers with code they actually have to *write* (and therefore
read and maintain), rather than just generate. If it happens to help
with the latter as well, that's great.
Mark
On 25 Mar 2009, at 13:41, james lowden wrote:
>
> I'd like to see both. Auto-getters/setters/equals/etc. would be
> really, really nice, but it would also be valuable to have a way of
> specifying a variety of different constructors to generate, which
> Mark's proposal would allow for. Example:
>
> public data class Foo {
> private final int x;
> private final int y;
> private final String foo;
>
> public Foo (this.x) {}
>
> public Foo (this.foo, this.y) {}
> }
>
>
> (I eliminated the types from the automagical constructors, as they
> can be inferred by the compiler.)
More information about the coin-dev
mailing list