Are constants supported in ColdFusion?
No, ColdFusion does not have constants. I think in most cases developers just set a variable, using some naming convention such as the variable name in ALL_CAPITALS, and then never change it's value. This is not really a constant as in other languages and you really have to be careful that the value is not changed (because it is not a true constant). I have done this before and typically set these "constants" in the application scope so they are readily available.
There was an enhancement request opened a while back. However, it looks like it has been closed and deferred.
Adam Cameron blogged about this very thing last year and references the same enhancement request.
No, not as a native language feature. the key bit in the page you linked to is "ColdFusion does not allow you to give names to constants"
I think the page is really talking about literals, rather than constants.
If you want to support unmodifiable constants, I think you'd need to use an object to encapsulate the values:
component displayname="constant values for my app" {
property name="mailServer" default="127.0.0.1" getter=true setter=false
property name="password" default="supersecret" getter=true setter=false
}
You could then set this in whichever scope you need it (e.g. application or request) then call application.constants.getMailServer()
It's not as concise as the @Miguel-F solution, which is the one I'd use most of the time, but it's here as another option.