Ontology of Name Binding
We constantly struggle to name things involved in name binding. Take the following two rules:
Foo(x): defines NS x Bar(y): refers to NS y
We need names for the following things:
Foo(x)
. We currently tend to call this definition site ofx
.x
insideFoo(x)
. Whilex
in general is a name, how do we call it at the position where it is defined. Is this the definition site ofx
? If so, what isFoo(x)
?Bar(y)
. We currently tend to call this use site ofy
.y
insideBar(y)
. Again,y
in general is a name, how do we call it at the position where it is used. Is this a use site ofy
? If so, what isBar(y)
?Another issue is scope. We use scope as a level of visibility. Classes scope methods, methods scope variables. In other texts, a scope is a property of a name. The scope of a variable is …
Submitted by Guido Wachsmuth on 8 March 2013 at 16:21
Issue Log
The term is the definition/use site and the name is the identifier (or just name) of the site. Why do we need to name these sites anyway, aren’t they just used for matching?
The scope of a variable is a hierarchical (or just ordered) list of identifiers (from definitions that scope, or from anonymous scopes) that encapsulate the visibility of the variable?
@Gabriel: when explaining the language we need to have names for the parts that play a role in name binding.
@Visser: I know, but wouldn’t it be just a (pattern) match? To make my question more clear: where do we use the fact that Foo(x) is called a definition site?
@Gabriel: “where?” when explaining the concepts of name binding to new users of Spoofax.
@Visser http://orly.imagefail.com/
But I already answered my own question. When explaining vertical scopes the definition site tells you in which child terms the definition is visible, so we indeed need to name it.
What about these names?
Language (instance):
foo a bar a
Meta naming:
- Foo(x): defines NS x - binding rule
- Foo(x) - pattern match
- defines NS x - defines declaration
- refers to NS y - refers to declaration
Name binding naming:
- Foo(x) - definition site
- Bar(y) - use site
- x/y - identifier, name
- foo a - definition with name/identifier “a” in namespace NS
- bar a - reference to name/identifier “a” in namespace NS
// whole thing: binding rule
Class(x, y, _): // binding context pattern
defines Class x // defines clause
imports Field, Method from Class y // imports clause
scopes Field, Method // scoping clauseClass(“A”, “B”, [])
// binding context
// “A” and “B” are names (identifiers)
// “A” is binding instance
// “B” is bound instance
Class(“B”, “C”,[])
// “B” is binding instance
// “C” is free instance
Log in to post comments