[Grace-core] Edited Variable & Constant page

Andrew P. Black black at cs.pdx.edu
Mon Nov 15 22:03:46 PST 2010


Ah, I see the problem.  While reading the whole of that post, I assumed that we were talking about temporary variables and invariables.

Now I have figured out that you are talking about instance variables and invariables.

Maybe we should distinguish them syntactically?  This distinction is a really important one to teach, and using the same syntax for two very different concepts is arguably a bad idea.

	private field x

or 
	private field x: Number

declares an instance variable that can be bound, and re-bound, inside the object.

private is optional, but it is the default if omitted.

	readonly field x

is the same, except that it also builds a method called getX (oh, I hate that 'get' stuff; it's the price of being able to omit self) that can be sent to the object to access x's value.

	readwrite field x: Number

is the same, except that it also builds a method called setX() that assigns it's argument to x.

And then we can have private const x, readonly const x, etc. for the invariables.

	Andrew



On 14 Nov 2010, at 1:03, James Noble wrote:

>> 
>> 	let x ;
> 
> yep. unfortunately there are times when we need that or something like it: for "per instance"
> dynamically typed constants that will be initialised in initialisers.
> 
> perhaps

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20101115/7ea1bb3f/attachment.html>


More information about the Grace-core mailing list