Prev Up Next
Go backward to 5.2 Abstract Syntax
Go up to 5 Our Proposal More in Detail
Go forward to 5.4 Semantics

5.3 Static Semantics

The condition for static semantics are the standard ones plus a coherence requirement, imposing that generic symbols from one parameter type cannot be used as fixed symbols in any parameter type within the same generic specification.

5.3.1 PAR-TYPE

A declaration par-type Sp fixed-names Sp1...Spn in an environment is well-formed if Sp is any well-defined expression of type SPEC and the signature of each Spi is a subsignature of the signature of Sp. (Actually, in most cases we expect that each Spi is, loosely speaking, a subexpression of the expression defining Sp.)

5.3.2 Definition

Let us consider a definition gen-spec-defn GSP gen-spec Par_1...Par_n Sp_Body where each Pari is Xi1...Xiki par-type Spi fixed-names Spi1...Spimi .

Let us denote by FNi (for Free Names) the generic symbols of the ith-parameter type, that is the symbols of the signature of Spi that do not appear in the signature of any Spij.

Then, such declaration is well-formed in an environment if each Pari is well-formed and moreover the following conditions hold:

Coherence
Symbols in any FNi cannot belong to the fixed part of other parameters. Notice that the signatures of different parameters are not required to be disjoint; indeed the intersection of the generic parts of the signatures of different parameters may be non-empty, as well as the intersection of their fixed parts. In particular, several parameters with the same PAR-TYPE are allowed.
No double declarations
Each parameter name can occur at the most once in the list of formal parameters of a generic spec, as usual.
SpBody
Symbols in the signature of any parameter cannot be redeclared in the body SpBody.

The body of a generic spec has to be well formed in the current environment enriched by the parameter names, that are assumed to have the signatures described by the corresponding qualifying specs Spi.

Moreover, the body must be unambiguous. Following the principle that generic symbols are just place holders, such symbols cannot be confused with generic symbols declared (with the same profile, if it is a function or a predicate) in the qualifying specification of some other parameter. Thus, if a symbol name (with the same profile, if it is a function or a predicate) belongs to FNi and FNj for i/=j, then it must be referred to using its source as well as its name.

This requires the following changes to the abstract syntax as well

SORT      ::= ... | referenced-sort SORT-NAME SPEC-NAME
FUN-NAME  ::= ... | referenced-fun FUN-NAME SPEC-NAME
PRED-NAME ::= ... | referenced-pred PRED-NAME SPEC-NAME
where the referenced constructs is well formed only within the body of a generic specification with the SPEC-NAME part corresponding to the name of (one of) the formal parameters, whose signature includes in its varying part that symbol name.

The body of a generic spec can be any kind of expression not only an extension of a union (as in the current proposal), but notice that if the parameters have to be (persistently) extended, then this has to be explicitly stated in the body.

5.3.3 Instantiation

An instantiation is statically correct iff acceptable fitting parameters are provided for all formal parameters (in the same order).

An acceptable fitting parameter corresponding to a formal parameter of type par-type Sp^i fixed-names Sp^i_1...Sp^i_k^i consists of


CoFI Note: L-3 --DRAFT, Version 0.2-- 21 May 1997.
Comments to cerioli@disi.unige.it

Prev Up Next