Modular C
Modules and composed identifiers
Synopsis:
#pragma CMOD module [ abbrev = ] long-name
#pragma CMOD separator character
#pragma CMOD composer character

The central feature of Modular C to access features (variables, functions, macros, ...) across different modules are composed identifiers. Each module has a name that is usually composed of several particles. E.g in the C library interface there is a module

#pragma CMOD module C◼real◼double

The three components of this composed identifier are C, real, double. This composed identifier states that the feature that it refers to is member of a module C◼real which in turn is a member of the module C.

The character between the components is called separator. It can be chosen almost freely, just as the coding style of the project imposes. For example

#pragma CMOD module C¯real¯double

could have worked equally well if we wanted the separator to be ¯ instead of , see Unicode.

This naming scheme extends to the members of each module. Each non-composed identifier that is used in a module receives the module name as a prefix to form its external name. E.g the module C◼real◼double has a member called SIZE and so the external name is C◼real◼double◼SIZE. This naming scheme is independent of the separator character. If another module uses , it would refer to the same feature by using C⋏real⋏double⋏SIZE.

This composition feature of identifiers helps to ensure uniqueness across different modules. E.g other modules could also have a member SIZE that can clearly be distinguished from C◼real◼double◼SIZE.

Next: Identifier visibility