Repository navigation
Language Specification (11) : Blueprints
Blueprints are optional pre-compilation units to assure completeness and consistency of library interfaces expected to follow a common API.
blueprint :
BLUEPRINT blueprintIdent ';'
( INHIBIT bindSpec ( ',' bindSpec )* ';' )?
( bpConstDeclOrDefn | bpTypeDeclOrDefn | bpProcDecl )+
END blueprintIdent '.' ;Example:
BLUEPRINT ProtoCardinal;
INHIBIT [ABS], [SGN];
CONST [SXF], [TMIN], [TMAX];
TYPE ProtoCardinal = OPAQUE(CARDINAL);
PROCEDURE [+] sum ( left, right : ProtoCardinal ) : ProtoCardinal;
...
END ProtoCardinal.A library interface may reference a blueprint in its module header to declare conformance. The interface is said to follow the blueprint.
interfaceModule :
INTERFACE MODULE moduleIdent ( '[' blueprintIdent ']' )? ;An interface module that declares conformance to a blueprint must provide declarations or definitions for all the syntactic entities given in the blueprint, and it must not provide any bindings listed in the blueprint's INHIBIT list. Identifiers of constants and procedures that are not syntax bound must match the corresponding identifiers given in the blueprint. Other identifiers do not need to match.
Example:
INTERFACE MODULE CARD128 [ProtoCardinal];
TYPE CARD128 = OPAQUE(CARDINAL);
CONST [TMIN] TMin = { 0x00 REPEAT 16 };
CONST [TMAX] TMax = { 0xFF REPEAT 16 };
PROCEDURE [+] sum ( left, right : CARD128 ) : CARD128;
...
END CARD128.A language processor must enforce syntactical correctness of the module header, including blueprint references, but it is not required to verify blueprints nor is it required to verify blueprint conformance. Instead, blueprint conformance shall be verified before any compilation run. For this purpose a separate tool called the Modula-2 Blueprint Guardian (m2bpg) is employed. The build tool (m2make) shall determine which interfaces declare conformance to a blueprint and invoke m2bpg on each such interface prior to its compilation.
Copyright © 2015-2018 Modula-2 Software Foundation