1

In C++, is there a difference between name binding and name lookup in? The working draft C++14 standard (N4296) defines name lookup in (3.4) as

Name lookup associates the use of a name with a declaration (3.1) of that name.

I can't find a definition for name binding in the standard, but the IBM Knowledge Center documentation for their XL C/C++ compiler defines:

Name binding is the process of finding the declaration for each name that is explicitly or implicitly used in a template.

The only distinctions between the two definitions seem to be that (1) name binding refers specifically to a name used in a template and (2) name binding refers to a name, while name lookup refers to the use of a name.

However, Section (13.3) on Overload Resolution in the C++ standard mentions binding frequently, but without defining it. The way 'binding' is used in this context makes it seem that binding refers to the association of an argument with a function parameter.

At first, this definition seems different from either of the other two definitions, thought it fits (broadly) the definition of name lookup if we assume that the name of the function is being bound to its declaration by comparing the types of arguments and parameters. That isn't exactly the sense used in Section (13.3), but I'm trying to make sense of the standard without a proper definition.

In short, if anyone has a good definition of 'name binding' or 'binding', I'd be grateful.

gihan
  • 53
  • 6
  • "However, Section (13.3) on Overload Resolution in the C++ standard mentions binding frequently" But not name binding, which is used only once in the whole document, possibly a bug. –  Apr 03 '17 at 23:27

1 Answers1

1

Having read the relevant parts of Wilson & Clark Comparative Programming Languages, I think I have a better understanding of the topic. If I surmise correctly, the term 'binding' covers a gamut of related terms, including name-declaration binding, name–type binding, declaration-reference binding, reference-value binding, and name-value binding.

"Name lookup" seems to be a synonym for name-declaration binding. The other uses of 'binding' in the C++14 standard relate to various combinations of the other varieties of binding.

Please correct me if I'm wrong!

gihan
  • 53
  • 6