News & Events

  • Andrew Lumsdaine, Jeremiah Willcock, Marcin Zalewski, Larisse Voufo had a submission for a presentation at the next C++Now (May, Aspen, CO) accepted

    Date: 03/29/2013

    Weak Hiding for C++ Concepts: via a Framework for Reasoning about Name Binding in Programming Languages.

    C++’s name lookup and overload resolution rules are complicated (combining traditional scoping, argument-dependent lookup, template argument deduction and SFINAE, and overload resolution), and the proposals for adding concepts to the language complicate those rules even further. Explor- ing alternative designs to find the best set of name lookup and overloading rules for concept-enabled C++ is difficult due to the opacity of the current rules, impairing research in this area. To explicate the rules (both current and proposed), we present a unified framework for describing systems for name lookup, a.k.a. name binding, in programming languages. The framework can describe the current rules, as well as provide a simplified approach to understanding and exploring the effects of concept proposals on name lookup (and overload resolution). The model expresses the subtle differences between different languages and potential extensions, the complexity of ADL, and areas of misunderstanding of the standard rules for checking uses of operators. Furthermore, it allows us to investigate implementations of concepts for C++ as extensions of existing compilers, e.g., the ConceptClang extension of Clang.

    For example, the specification of name lookup and overload resolution in the last draft (N2914) of the C++ standard containing concepts invalidates seemingly-correct code—that is valid under the current rules—when it is placed in a constrained template. The design decision made in N2914 that causes this problem is that names in constraints either shadow definitions of those names outside the template (including in outer scopes and associated namespaces), or are treated equally to others, based on whether they are operators. In either case, overload resolution follows name lookup and without affecting it. We propose, and use our framework to understand, a different alternative: “weak hiding”, an intermediate approach in which names in the surrounding scopes (and associated namespaces) are hidden only if overload resolution succeeds using only names in the template’s constraints. In our unified framework for name binding, this model is expressed using four combinators between scopes, named hiding, no hiding, opening (for ADL), and weak hiding, and other related ideas that are minimally abstracted into two concepts, Language and Design. This presentation will summarize our name binding infrastructure and major findings, and focus on introducing weak hiding for checking name uses in constrained template definitions. First, we will demonstrate the need for weak hiding with practical examples addressing issues from the perspectives of both novices and experts. Then, we will address its implementability, which will explain some design decisions that we have made for ConceptClang. After this session, the audience is intended to better understand the subtleties of C++ name lookup rules, both current and the alternatives under consideration for extending these rules with support for concepts (including weak hiding).

 

 

----------