Ben Nadel – At It Again

Ben Nadel posted another interesting code snippet this moring.  I think Ben and I stand in agreement on the technique: NEVER EVER USE IT.  It leverages a horrible bug in ColdFusion's implementation of struct literals that I've blogged about previously.

Here's the snippet:

<cfset objConfig = {
  root = getDirectoryFromPath(getCurrentTemplatePath()),
  tags = objConfig.root & "tags/",
  com = objConfig.root & "com/"
} />

Yes, that actually works.  Let me repeat, NEVER EVER USE IT.  It is the devil incarnate, and only works because of a horrible implementation error in Adobe ColdFusion.  Note this is a ColdFusion bug, not a CFML language issue.  Railo implements struct literals correctly (as well as treating them as expressions instead of statements).  I don't know about OBD – the last time I used it there wasn't struct literal support at all, but it's been a while.

One response to “Ben Nadel – At It Again”

  1. Ben Nadel

    Just for the record, I was not advocating using it, I was just experimenting :) Just don't people to get the wrong impression.

    I really hope this gets fixed in CF9!