Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created July 9, 2017 16:09
Show Gist options
  • Save nikomatsakis/bf56ba766378ff15f7fadc515fb67598 to your computer and use it in GitHub Desktop.
Save nikomatsakis/bf56ba766378ff15f7fadc515fb67598 to your computer and use it in GitHub Desktop.
fn foo(x: fn(&T), y: &U)

                fn foo
              x /     \ y
              fn       &
              |        |
              &        U
              |
              T

In the case of the &T type that is part of x, debruijn index of 1 refers to the fn, and 2 refers to the fn foo.

In the case of the &U type that is part of y, debruijn index of 1 refers to the fn foo.

general rule: debruijn index goes upwards in the tree, stopping at each fn (or other place where regions can be bound -- typically functions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment