docs.intersystems.com
Home  /  Application Development: Core Topics  /  Orientation Guide for Server-Side Programming  /  Rules and Guidelines for Identifiers


Orientation Guide for Server-Side Programming
Rules and Guidelines for Identifiers
[Back]  [Next] 
InterSystems: The power behind what matters   
Search:  


For convenience, this appendix summarizes the rules for ObjectScript identifiers in all server-side contexts and provides guidelines to avoid name collisions.
Also note that 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 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, and DOCUMATIC. Some of these namespaces are described in System-Supplied Namespaces,” earlier in this book. Others are used internally by InterSystems IRIS.
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.
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 ObjectScript:
Local Variable Names to Avoid
Avoid using the following name for local variables:
Global Variables
For the name of a global variable, the following rules apply in ObjectScript:
Global Variable Names to Avoid
When you create a database, InterSystems IRIS 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 ObjectScript:
Note that certain %Z routine names are reserved for your use. See the subsection.
Reserved Routine Names for Your Use
InterSystems IRIS 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 InterSystems 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:
Also, 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 InterSystems 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.
CACHESYS Database and Custom Items
You can create items in the CACHESYS database. For the next release of InterSystems IRIS, the installer will upgrade this database. During this upgrade, some items will be 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.