# Naming Scopes

An identifier is a sequence of characters which contains Latin letters, underscores (_), decimal digits and those Unicode characters which are classified as alphanumeric. An identifier must not start with a digit. In HTSQL, identifiers are used to refer to classes, attributes, links, functions, constants, predefined expressions, and other objects.

Each identifier in the input query is resolved to determine the object denoted by it. How an identifier is resolved depends on the form of the identifier itself and the position of the identifier in the input query. In this section, we describe in detail how HTSQL processor resolves identifiers.

## Identifiers

In HTSQL, an identifier could be used in three different forms: plain, functional and referential.

### Plain Identifiers

We call an identifier plain when it does not appear in a function or a reference form. Plain identifiers are used to refer to data model objects such as classes, attributes and links, and also to global constants.

This query contains four plain identifiers: school, name, campus and null, which refer respectively to a class school, class attributes school.name and school.campus, and a constant null.

### Function Calls

An identifier is said to be in a functional form (or just a function) when it is a part of a function call expression. HTSQL supports two notations for function calls: prefix (F(x,y,...)) and infix (x :F (y,...)); the choice of calling notation has no effect on name resolution.

It is convenient to treat unary and binary operators as functions with one or two arguments. In HTSQL, operators use the same mechanism for name resolution as regular functions.

This query contains:

• count(), csv(): functions with one argument;
• as(): a function with two arguments;
• /: an unary operator (two occurrences);
• ?, =: binary operators.

The query uses both prefix and infix call notation. Rewritten to use the prefix notation only, the query takes the form:

### References

An identifier appears in a reference form if it is preceded by $symbol. References are used to pass values between different parts of the query. Often, references serve as parameters of predefined expressions. Here, reference$avg_credits denotes the average number of credits across all courses.