by Michael Dinowitz
In Knowledge base Article 14192 (listed above), Allaire has put out a new list of words that are reserved in ColdFusion. No disrespect to them, but they really didn't go into why these words are reserved or where. I'll be going over the three basic groups of reserved words, where they are used and why they are reserved.
Before we start, let me define the term 'word' as meaning any string of letters, numbers, or the underscore, that starts with a letter and can be used as a variable. This definition is actually very important and we'll be using it frequently.
| AND | CONTAINS | EQ | EQUAL |
| EQV | GT | GTE | IMP |
| IS | LT | LTE | MOD |
| NEQ | NOT | OR | XOR |
Interestingly, the words DOES, CONTAIN, GREATER, LESS, THAN, and TO are not reserved by ColdFusion. (I prefer not to use these words as variables just to be on the safe side.) I believe that the reason has to do with how ColdFusion evaluates the entire CFIF statement. Notice that all the reserved words can be used singly, while the words that are not reserved are part of a longer statement like 'GREATER THAN.' I believe that if ColdFusion can not find a single comparison operator, it looks at the word combinations in the statement to see if any of them combine to make one of the longer statements. Theoretically, this should add some time to the processing of a CFIF that uses the longer comparison operators, but this is not the case. Any time differences would be very miniscule (and they are).
A final note about this group of reserved words is that they can NEVER be used as the variable in a CFSET. ColdFusion automatically recognizes them and prevents their use.
| VARIABLES | URL | FORM | CGI |
| CLIENT | SERVER | SESSION | APPLICATION |
| ATTRIBUTES | REQUEST | THISTAG | CALLER |
| COOKIE | CFFTP (CFFTP) | CFHTTP (CFHTTP) | ERROR (CFERROR) |
| FILE (CFFILE) | CFCATCH (CFCATCH) |
This does not mean that you can not use the name of a scope as a variable. Unlike the previous group of reserved words, you can use one of the scopes above as the name of a variable. CFSET will not stop you or throw any sort of error. On the other hand, it will overwrite the structure that already exists. This can have the effect of destroying a user's session by setting a variable named session to some value. Not a great idea.
Also note that while I included ALL of the scopes in the table above, some of them are not actually structures. Variables in the Server and Variables scopes are all stored by ColdFusion as individual units of data rather than as structures. I expect that to change for the Variables scope eventually, but Allaire has held off turning the Server scope into a structure for security considerations. (You can hide stuff in the Server scope and there's no way anyone can access the variables without knowing their exact names.)
| FOR | WHILE | DO | IF |
| ELSE | SWITCH | CASE | BREAK |
| DEFAULT | IN | CONTINUE |
In the past, ColdFusion did not have a lot of reserved words nor any hard rules for what variable names to use. As ColdFusion becomes more of an industry-accepted 'language,' it is getting more structured, and the rules of when and where you can do something are getting more specific. This is actually a good thing, as it will help prevent people from writing sloppy code. I can just see someone writing a value to a variable called Url and then not having access to his passed Url variables anymore.