Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Nested parent aliases #20

Closed
rossberg opened this issue Dec 8, 2020 · 4 comments
Closed

Nested parent aliases #20

rossberg opened this issue Dec 8, 2020 · 4 comments

Comments

@rossberg
Copy link
Member

rossberg commented Dec 8, 2020

Currently, parent aliases can only refer to the innermost parent. When nesting multiple levels, it may be necessary to reference definitions from an even outer scope. While this could be expressed by inserting an alias on each level and chaining them up, it seems natural enable parent aliases to point to any enclosing scope directly.

For example, instead of

(module
  (type (func))
  (module
    (alias parent (type 0))
    (module
      (alias parent (type 0))
      (func (type 0))
    )
  )
)

directly allow

(module
  (type (func))
  (module
    (module
      (alias (parent 1) (type 0))
      (func (type 0))
    )
  )
)

where the parent is indexed relatively (de Bruijn-style), with the innermost one being 0. If omitted, it defaults to 0.

Or as a symbolic shorthand (cf. #19):

(module $A
  (type $ t(func))
  (module $B
    (module $C
      (func (type (parent $A) $t))
    )
  )
)

where we allow to use the symbolic name of modules to name parents.

This becomes more relevant once type imports induce more complicated type dependencies.

@lukewagner
Copy link
Member

That makes sense to me.

@rossberg
Copy link
Member Author

rossberg commented Dec 9, 2020

FWIW, "parent" can mean many things, so I would also have a preference for replacing that keyword with outer or something similar, especially when an outer scope may be both a module or a module/instance type (cf. #21).

@lukewagner
Copy link
Member

Good point. Now that you mention it, I also have a distinct notion of "parent" brewing in a totally different context.

@lukewagner
Copy link
Member

Fixed with #26

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants