gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

Shadowing #98

Open kjx opened 8 years ago

kjx commented 8 years ago

what should the shadowing rules be (raised by Kim)

kjx commented 6 years ago

I still don't know what the shadowing rules are (see also #75, #140, #141).

There seem to be two parts:

The most general rule is: all declarations are forbidden from shadowing, and all declarations cannot be shadowed: !findInternalDeclaringContext(name).isMissing (we do a lookup and we find a preëxisting definition). That rule, for example, forbids the following because bar.inner.x would shadow the x method in bar inherited from foo:

class foo {
    method x { "X" }
}

class bar {
    inherit foo
    class inner {
        method x { "XXXXX" }
        method y(x) { "YYYY" }
    }
}

Or (along each axis):