Caché Programming Orientation Guide
Rules and Guidelines for Identifiers
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Search:    

For convenience, this appendix summarizes the rules for Caché ObjectScript identifiers in all server-side contexts and provides guidelines to avoid name collisions.

Also note that Caché ObjectScript does not have reserved words, so if you use a command as an identifier, the result is syntactically correct, but the code is also potentially confusing to anyone who reads it.
For identifiers for security entities such as users, roles, and resources, see the relevant section of the Caché Security Administration Guide.
Namespaces
In a namespace name, the first character must be a letter or a percent sign (%). The remaining characters must be letters, numbers, hyphens, or underscores. The name cannot be longer than 255 characters.
Namespace Names to Avoid
The following namespace names are reserved: %SYS, BIN, BROKER, DOCBOOK and DOCUMATIC. Some of these namespaces are described in System-supplied Namespaces,” earlier in this book. Others are used internally by Caché.
Also, if you use the namespace name SAMPLES, you must take care not to install the InterSystems code samples database, which uses that namespace.
Databases
In a database name, the first character must be a letter or an underscore. The remaining characters must be letters, numbers, hyphens, or underscores. The name cannot be longer than 30 characters.
Database Names to Avoid
The following database names are reserved: CACHE, CACHESYS, CACHELIB, CACHEAUDIT, CACHETEMP, and DOCBOOK.
Also, if you use the database name SAMPLES, you must take care not to install the InterSystems code samples database, which has that name.
For information on these databases, see System-supplied Databases,” earlier in this book.
Local Variables
For the name of local variable, the following rules apply in Caché ObjectScript:
Local Variable Names to Avoid
Avoid using the following names for local variables:
Global Variables
For the name of a global variable, the following rules apply in Caché ObjectScript:
Global Variable Names to Avoid
When you create a database, Caché initializes it with some globals for its own use. Also, every namespace that you create contains mappings to system globals, including global nodes that are in writable system databases.
To avoid overwriting system globals, do not set, modify, or kill the following globals in any namespace:
Routines and Labels
For the name of a routine or for a label, the following rules apply in Caché ObjectScript:
Note that certain %Z routine names are reserved for your use. See the subsection.
Reserved Routine Names for Your Use
Caché reserves the following routine names for your use. These routines do not exist, but if you define them, the system automatically calls them when specific events happen.
Classes
For any class, the full class name has the following form: packagename.classname
The rules for class names are as follows:
Class Names to Avoid
For persistent classes, avoid using an SQL reserved word as the short name for the class.
If you use an SQL reserved word as the short name for a class, you will need to specify the SqlTableName keyword for the class. Also, the mismatch between the short class name and the SQL table name will require greater care when reading the code in the future.
For a list of the SQL reserved words, see Reserved Words in the Caché SQL Reference.
Class Members
For a class member that you create, unless the name of that item is delimited, the name must follow these rules:
As of release 2012.2, member names can be delimited. To create a delimited member name, use double quotes for the first and last characters of the name. Then the name can include characters that are otherwise not permitted. For example:
Property "My Property" As %String;
Member Names to Avoid
For persistent classes, avoid using an SQL reserved word as the name of a member.
If you use an SQL reserved word for one of these names, you will have to do extra work to specify how the class is projected to SQL. For example, for a property, you would need to specify the SqlFieldName keyword. Also, the mismatch between the identifier in the class and the identifier in SQL will require greater care when reading the code in the future.
For a list of the SQL reserved words, see Reserved Words in the Caché SQL Reference. Notice that this list includes many items with names beginning with %, such as %UPPER and %CONTAINS. Such items are InterSystems extensions to SQL, and additional extensions may be added in future releases.
Custom Items in CACHESYS
You can create items in the CACHESYS database. When you install a Caché upgrade, this database is upgraded. During this upgrade, some items are deleted unless they follow the naming conventions for custom items.
To add code or data to this database so that your items are not overwritten, do one of the following:
MAC code and include files are not affected by upgrade.