[Grace-core] Edited Variable & Constant page

Andrew P. Black black at cs.pdx.edu
Mon Nov 15 23:33:11 PST 2010


I was imagining a different distinction.

On 15 Nov 2010, at 23:21, James Noble wrote:

> but I don't understand what a "readonly const" is?

We haven't (yet) figured out how,or if, to have access control on methods.  So I was imagining the Smalltalk rule that fields can only be accessed inside their object.  Declaring a field readonly creates a method that other objects can use to read that field's value; this makes just as much sense for const fields as for var fields.   If the field is private, then there s no such method, and the field can be accessed only from inside the owning object, by using the field's name directly.

> 
> the other difficultly with "field" is that I was hoping to use the *same* syntax
> for declaring fields in objects  and locals in blocks.  Here, this follows
> Self and Beta (and arguably Simula)

No, Smalltalk used the same syntax to declare locals in methods and locals in blocks.  Fields are declared quite differently (in the message that creates the class itself.)  I don't lnow about self.

> 
> the difficulty with "const" is, well
> readonly const x = HighlyVolatileMutableClass.new;   // urgh. How is this const?
> 
It's const because the binding between x and the HighlyVolatile object never changes.  There is no need to ever read x more than once.   You can cache it safely; if I do obj.x now and obj.x later, I can be sure that they are egal.

	Andrew


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


More information about the Grace-core mailing list