PROPOSAL: Auto-assignment Parameters

Mark Mahieu markmahieu at
Fri Mar 27 16:32:20 PDT 2009

On 27 Mar 2009, at 15:10, Vilya Harvey wrote:

> I think the general idea here is great, but I also think the original
> proposal tries to be too specific about what gets auto-assigned. The
> main use cases are constructors, getters and setters; so how about
> just being able to declare those items as having an automatically
> created implementation rather than specific parameters to them?
> You could use the "default" keyword (for example) as a modifier in a
> similar way to "abstract": methods and constructors declared with it
> would be prevented from having a body and the compiler would provide
> it instead (or report an error if it couldn't). The method bodies that
> the compiler generates could be kept pretty simple. For example, this:

The use cases are rather different, to my mind - the Auto-assignment  
Parameters proposal really isn't aimed at generating whole  
constructor/method implementations, even though it can be used that  
way; in fact, fitting in well alongside programmer-supplied code (in  
the constructor body) is a primary design goal, as it's common to  
want to do much more than just assign the parameters to some fields.   
Validating the parameters, or initializing other fields would be  
common examples.

Many of the classes I'd want to apply it to simply don't fit in with  
the bean-style getter/setter conventions anyway.

For the use cases you describe though - where a straightforward auto- 
generation approach *is* what's wanted - your suggestion seems quite  
nice in many respects.  I suspect it falls firmly into the  
'properties support' category of language change, which I'd also  
welcome progress on, personally.  I think the two are largely  
orthogonal though.


More information about the coin-dev mailing list