Here's the upshoot from something that bubbled up on Twitter. I'll spare you the replicated timeline this time, and just cut to the chase...
After a brief exchange with Carl Von Stetten, Steve Neiland and Luis Majano on Twitter, I decided to raise these tickets:
Allow the type of variables to be specified
(ColdFusion: 3687548; Railo: RAILO-2814)It would be good to be able to do this:(I added a comment to the ColdFusion one about it being lousy at guessing which type a variable should be stored as, but this does not apply to Railo, so I omitted it here).
<cfset int myInt = 42>
And have CF treat that *as an int*, thereafter. myInt can only take another int as a value, it can only be used for int-type operations, needs to be specifically cast to another type if need be.
Sometimes it's great to be loosely typed. Sometimes it's a real pain in the arse to be so flippant with data typing.
Now - to be clear - I'd say 95% of the time being loosely typed is fine. And to a lesser degree being dynamically typed makes life easy too (although changing types of a variable halfway through its life seems like a code smell to me, TBH), but there are a lot of times when I know something is an integer, it will always be an integer, and I don't want anything thinking it might be anything other than an integer. So being able to say "IT'S A BLOODY INTEGER" would be handy.
I'd use this every day. Too much of my work is trying to trick CF (less often Railo) into just listening to me when I say a variable is a specific type, even though it might look like some other type.
You? Thoughts?
--
Adam