[Grace-core] Summer Plans
James Noble
kjx at ecs.vuw.ac.nz
Mon Jun 18 15:26:11 PDT 2012
On 19/06/2012, at 05:51 AM, Andrew P. Black wrote:
>
> Using the class construct, there is no place to declare temps that have the lifetime of the constructor method.
> Any name that would be declared in the constructor method becomes a field of the object, even though you might
> not want it to be one.
yes. that's right.
> One way of looking at this is to say that we designed the class syntax to be a shorthand for a particular kind of object in which there was one method (the constructor method) that had as its body a single object constructor.
That's how I'd put it.
> These are common, but certainly don't encompass all constructor objects.
right. And the preferred work-around is either to write out nested objects,
or just write a facade that calls the "primary" constructor of the class - which has basically the same effect.
Another way around it would be to explicitly introduce multiple constructors / factory methods that would desugar to a call on the primary constructor. This does complicate the language design and explanation thought, so I'd want more compelling examples before we moved there (perhaps from the libraries?).
> A third solution is to change the rule that every def automatically generates a method. If un-annotated defs don't create methods, but those annotated <readable> do, then there is no problem using
again, let's not...
James, jetlagged
More information about the Grace-core
mailing list