Identifier: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
Line 23: Line 23:
== Recommendations ==
== Recommendations ==


It is recommended to write identifiers in camel-case-syntax. That means that all sub-words in the identifier are started with an upper-case character.
It is recommended to write identifiers in camel-case-syntax. That means that all sub-words in the identifier are started with an upper-case character. This makes identifiers better readable.


'''Examples:'''
'''Examples:'''


  myCamelCaseIdentifier
  myCamelCaseIdentifier
Another but longer method is to split all sub-words with underscores.
'''Examples:'''
my_splitted_identifier


[[Category: ArmA: Scripting]]
[[Category: ArmA: Scripting]]
[[Category: Scripting Topics]]
[[Category: Scripting Topics]]

Revision as of 00:46, 22 December 2006

An identifier is a name given to a variable that the scripter can choose: It is the name that identifies the variable.

Rules

Binding rules for identifiers:

  • Identifiers may consist of any ASCII characters (a-z, A-Z), numbers (0-9) and underscores (_)
  • Identifiers must not start with a number (f.i. "9myVariable")
  • Identifiers of local variables must start with an underscore

Examples of valid identifiers:

myVariable1
_localVariable95
_23Variable

Examples of invalid identifiers:

123Variable
9_vA#riable
_this&variable

Recommendations

It is recommended to write identifiers in camel-case-syntax. That means that all sub-words in the identifier are started with an upper-case character. This makes identifiers better readable.

Examples:

myCamelCaseIdentifier

Another but longer method is to split all sub-words with underscores.

Examples:

my_splitted_identifier