Sunday, July 18, 2010

On Reserved Words in Programming languages...


I just got bitten by IE when I inadvertently used 'class' as a variable name in Javascript. Firefox doesn't mind but IE generates an error (and I am glad it does). My reference (the David Flanagan "Javascript, The Definitive Guide", 4th Ed) shows that 'class' is not a reserved word in the ECMAScript (aka Javascript) Language definition, but is in the ECMA extension. I should not have used it anyway, I wasn't not paying attention, especially when Notepad++ was showing it as a reserved word in italic.


That's not the first time I encounter that issue, SQL has many variants and it's quite difficult to know and remember what words are reserved in which dialect of SQL. Using Hibernate or other layers on top of a SQL database complicates that as well. I spent some time in the past chasing a bug like this in one of my Grails applications.


So, in conclusion: if I was a good boy, I would get the list of reserved words of all the components that have some in each of my projects and keep them handy for a check when things look really weird, or as part of a final Q&A check.