5.2.2 Implicit Definition Directives

 

 def-directive = def-type  letter-spec *( "," letter-spec) 
 letter-spec = single-letter /  universal-letter-range / letter-range 
  
 single-letter = IDENTIFIER   ; %x0041-005A / %x0061-007A 
  
 universal-letter-range = upper-case-A "-"upper-case-Z 
 upper-case-A = IDENTIFIER 
 upper-case-Z = IDENTIFIER 
  
 letter-range = first-letter  "-" last-letter  
 first-letter = IDENTIFIER 
 last-letter = IDENTIFIER 
  
 def-type = "DefBool" / "DefByte" / "DefCur" /  "DefDate" / "DefDbl" / "DefInt" / "DefLng" / "DefLngLng" / "DefLngPtr" / "DefObj" / "DefSng" / "DefStr" / "DefVar" 

Implicit Definition directives define the rules used within a module (section 4.2) for determining the declared type (section 2.2) of implicitly typed entities (section 2.2). The declared type of such entities can be determined based upon the first character of its name value (section 3.3.5.1). Implicit Definition directives define the mapping from such characters to declared types.

Static Semantics.

  • The name value of the <IDENTIFIER> element of a <single-letter> MUST consist of a single upper or lower case alphabetic character (%x0041-005A or %x0061-007A).

  • The name value of the <IDENTIFIER> element of a <upper-case-A> MUST consist of the single character "A" (%x0041).

  • The name value of the <IDENTIFIER> element of a <upper-case-Z> MUST consist of the single character "Z" (%x005A).

  • A <letter-spec> consisting of a <single-letter> defines the implicit declared type within the containing module of all <IDENTIFIER> tokens whose name value begins with the character that is the name value of the <IDENTIFIER> element of the <single-letter> .

  • A <letter-spec> consisting of a <letter-range> defines the implicit declared type within the containing module of all entities with <IDENTIFIER> tokens whose name values begins with any of the characters in the contiguous span of characters whose first inclusive character is the name value of the <first-letter> <IDENTIFIER> element and whose last inclusive character is the name value of the <last-letter> <IDENTIFIER> element. The span can be an ascending or descending span of characters and can consist of a single character.

  • Within a <procedural-module-declaration-section> or <class-module-declaration-section>, no overlap is allowed among <letter-spec> productions.

  • A <universal-letter-range> defines a single implicit declared type for every <IDENTIFIER> within a module, even those with a first character that would otherwise fall outside this range if it was interpreted as a <letter-range> from A-Z.

 The declared type corresponding to each <def-type> is defined by the following table:

<def-type>

Declared Type

"DefBool"

Boolean

"DefByte"

Byte

"DefInt"

Integer

"DefLng"

Long

"DefLngLng"

LongLong

"DefLngPtr"

LongPtr type alias

"DefCur"

Currency

"DefSng"

Single

"DefDbl"

Double

"DefDate"

Date

"DefStr"

String

"DefObj"

Object reference

"DefVar"

Variant

 

If an entity is not explicitly typed and there is no applicable <def-type>, then the declared type of the entity is Variant.