7.3 Names

Identifiers are used to give names to several classes of languageobjects and refer to these objects by name later:

Naming objects

value-name::=lowercase-ident
( operator-name )
operator-name::=prefix-symbolinfix-op
infix-op::=infix-symbol
* ∣ + ∣ - ∣ -. ∣ = ∣ != ∣ < ∣ > ∣ or ∣ ||∣ & ∣ && ∣ :=
mod ∣ land ∣ lor ∣ lxor ∣ lsl ∣ lsr ∣ asr
constr-name::=capitalized-ident
tag-name::=capitalized-ident
typeconstr-name::=lowercase-ident
field-name::=lowercase-ident
module-name::=capitalized-ident
modtype-name::=ident
class-name::=lowercase-ident
inst-var-name::=lowercase-ident
method-name::=lowercase-ident

See also the following language extension:extended indexing operators.

As shown above, prefix and infix symbols as well as some keywords canbe used as value names, provided they are written between parentheses.The capitalization rules are summarized in the table below.

Name spaceCase of first letter
Valueslowercase
Constructorsuppercase
Labelslowercase
Polymorphic variant tagsuppercase
Exceptionsuppercase
Type constructorslowercase
Record fieldslowercase
Classeslowercase
Instance variableslowercase
Methodslowercase
Modulesuppercase
Module typesany

Note on polymorphic variant tags: the current implementation acceptslowercase variant tags in addition to capitalized variant tags, but wesuggest you avoid lowercase variant tags for portability andcompatibility with future OCaml versions.

Referring to named objects

value-path::=[ module-path . ] value-name
constr::=[ module-path . ] constr-name
typeconstr::=[ extended-module-path . ] typeconstr-name
field::=[ module-path . ] field-name
modtype-path::=[ extended-module-path . ] modtype-name
class-path::=[ module-path . ] class-name
classtype-path::=[ extended-module-path . ] class-name
module-path::=module-name { . module-name }
extended-module-path::=extended-module-name { . extended-module-name }
extended-module-name::=module-name { ( extended-module-path ) }

A named object can be referred to either by its name (following theusual static scoping rules for names) or by an access path prefix. name,where prefix designates a module and name is the name of an objectdefined in that module. The first component of the path, prefix, iseither a simple module name or an access path name1. name2 …,in case the defining module is itself nested inside other modules.For referring to type constructors, module types, or class types,the prefix canalso contain simple functor applications (as in the syntactic classextended-module-path above) in case the defining module is theresult of a functor application.

Label names, tag names, method names and instance variable names neednot be qualified: the former three are global labels, while the latterare local to a class.