Chapter 9. Names and Scopes

Table of Contents

9.1. Declarations
9.2. Determining the Meaning of a Name

Names are used to refer to entities declared in a programme, namely to packages, class or interface types, class predicates, members (class, interface, class predicate, field, method) of reference types, or local variables (which, for the purpose of this specification, include method, constructor, or exception handler parameters). Names in a programme are either simple, consisting of a single identifier, or qualified, consisting of a sequence of identifiers separated by '.' tokens. The following production defines this syntax of names:

[5]Name::=Identifier {'.' Identifier}  

The XL programming language makes use of names similarly to the Java programming language. However, there are new ways of declaring entities and new contexts and rules for the disambiguation among packages, types, variables, methods, and class predicates with the same name.

9.1. Declarations

A declaration introduces one or more entities into a programme and includes (implicitly for type- or static-import-on-demand declarations and instance expression lists) an identifier that can be used in a name to refer to these entities. A declared entity is one of the following:

  • A package, declared in a package declaraton.

  • An imported type, declared in a single-type-import declaration or a type-import-on-demand declaration.

  • An imported member, declared in a single-static-import declaration or a static-import-on-demand declaration.

  • A class, declared in a class or module declaration.

  • An interface, declared in an interface type declaration.

  • A member of a reference type, one of the following:

    • A member class, declared explicitly by a member class declaration or implicitly by a module declaration, in the latter case the identifier being equal to Predicate.

    • A member interface, declared by a member interface declaration.

    • A field declared in a class, interface, or module declaration, or the field length declared implicitly in every array type.

    • A method declared explicitly in a class or interface declaration, or declared implicitly by an instancing module declaration (the identifier being equal to instantiate) or by a module declaration (the identifier being equal to signature).

  • A local variable, one of the following:

    • A parameter of a method, constructor, or an exception handler.

    • A local variable declared in a block, an expression list, an instance expression list, a for-statement, a construction block, or on the right hand side of a transformation or instantiation rule.

    • A local variable named $, declared implicitly in an assignment or the left hand side of an instance expression list.

    • A query variable declared in a query.

  • A member of the type of the instance in an instance scope. Instance scopes occur in instance expression lists, on the right hand side of rules, and in instancing methods.

  • A class predicate, whose declaration is induced by a special class declaration (Chapter 12, Class Predicates).