Currently, the nested structure of choices does not prefer local definitions over imported definitions. This gave me some hard times with This() and Super():

Class(c, _, _): 
  defines Class c
  implicitly defines Field This() of type ClassTy(c)

This(): refers to Field This()

This works fine, until we have imports:

Parent(p):
  imports Field, imported Field, Method, imported Method from Class p
  implicitly defines Field Super() of type ClassTy(c)

Now This() is defined locally and imported from the parent, thus we have two valid resolutions.

Solution 1

A choice at the right place could let the local definitions win, but currently it does not.

Solution 2

Another direction would be more fine-grained specification of target scopes. For imports, we have already imported. We could use this also in refers clauses:

Super(): refers to imported Field This()

We could have more of these, for example local for local resolution:

This(): refers to local Field This()

Solution 3

Another option are scopes. We can currently say:

This(): refers to Field This() in current scope

Here, current is the default, and includes imports and surrounding scopes. We could have more variants there as well:

This(): refers to Field This() in local scope

This could be mixed with the namespace modifiers, e.g.

Super(): refers to imported Field This() in local scope

Solution 4

And finally, there is disambiguation. We might have more disambiguates:

This(): refers to innermost Field This()

Opinions? Preferences? Objections?

Submitted by Guido Wachsmuth on 3 July 2013 at 11:58

On 3 July 2013 at 11:58 Guido Wachsmuth tagged rfc

On 3 July 2013 at 18:25 Gabriël Konat commented:

What’s the difference between refers to local Field This() and refers to Field This() in local scope. Also, how would This(): refers to Field This() in local scope interact with scopes introduced by subsequent definitions? Maybe This(): refers to Field This() in local Class or This(): refers to Field This() in enclosing Class makes more sense for that case.


On 24 July 2013 at 00:39 Guido Wachsmuth commented:

@Gabriël: I just sketched different design options. Not all combinations make sense, because there are equivalents in different options. I basically asked for your preference to describe such things.

Log in to post comments