[Grace-core] Visibility of variables and constants in Objects
Andrew P. Black
black at cs.pdx.edu
Wed Jul 3 02:57:35 PDT 2013
On 3 Jul 2013, at 02:27 , James Noble wrote:
> method p {1}
>
> should be replaceable by
>
> var p = 1
> def p = 1
> var p = 1 is readable
> var p = 1 is public
> var p = 1 is readable, public
>
> (assuming the program has no definition of a p:= method)
>
> without changing the semantics of the program - even in the presence of inheritance
Why do you think that you should be able to change the program without changing it's meaning?
The only place where I expect that sort of behavior is when we define one thing as an abbreviation for another. So I would expect to be able to replace a class definition by a nested object definition without changing the meaning, because we define it that way.
Similarly, I view
def x is publiclyReadable = 1
as meaning
def _x = 1
method x {_x}
so I would expect to be able to replace either of these by the other without changing the meaning, assuming that _x is actually a fresh name.
> this is currently caught by "no shadowing" - the program should be rejected.
I was under the impression that Michael convinced us that the no shadowing rule was impractical and that we threw it out. Maybe my memory is faulty?
Andrew
More information about the Grace-core
mailing list