AdobeStock_455007340

Implicit Array And Structure Creation Revisited

To the delight of many a ColdFusion developer, in CF8 we added support for implicit array and structure creation. And now we’re taking this one step further in the ColdFusion 8 updater (due out shortly) to allow for arrays and structures to be nested. As an example, the following should work (and I did say “should”, this is planned, and plans change):

You get the idea. Oh, and before you ask, the updater is coming … soon!

14 responses to “Implicit Array And Structure Creation Revisited”

  1. Ben Nadel Avatar
    Ben Nadel

    Oh heck yeah 🙂

  2. Sam Farmer Avatar
    Sam Farmer

    I think you are missing an equal sign:
    cfevangelists = [{firstname="Ben", lastname="Forta"}, {firstname="Adam", lastname="Lehman"}]

  3. Ben Forta Avatar
    Ben Forta

    Good catch, thanks! Fixed.
    — Ben

  4. Steve Bryant Avatar
    Steve Bryant

    Good stuff!
    Any plans for <cftag mystruct="#{firstname=’Ben’,lastname=’Forta’}#"> ?
    Even if not, this is still a really exciting development.
    Thanks!

  5. Sam Farmer Avatar
    Sam Farmer

    Forgot to mention that this is a very cool new feature 🙂

  6. Rey Bango Avatar
    Rey Bango

    Thats hot!

  7. Tony Petruzzi Avatar
    Tony Petruzzi

    Finally. Don’t want to sound like a jerk, but this should have been fixed before cf8’s release. Without nesting implicit creation was useless.
    Now can they fix the Isvalid() integer bug and add an integer type to the cfargument tag. Little things like those make life hard.

  8. Radek Avatar
    Radek

    I have to agree with Tony. That was one of the most expected features. I don’t know how lack of nesting might pass QA. Many people complains MS releases beta versions but lack of nesting makes me think Adobe released somewhat beta version of CF. I am sure there is many more features like that.
    Anyway – good to see that coming!

  9. Joshua Curtiss Avatar
    Joshua Curtiss

    Ba-da-bing!

  10. Gary Gilbert Avatar
    Gary Gilbert

    Thats great news! I always thought the implicit structure and array creation was only "half" done in CF8 without the ability to nest. I do hope it allows for N levels of nesting 🙂

  11. Hansjoerg Avatar
    Hansjoerg

    Ben, will this be fixed and possible:
    a_component.StoreInformation( key = arguments.key, data = { firstname= a_str_firstname } )
    (posted here http://cfstuff.blogspot.com/2008/01/very-uncool-no-implicit-structure.html)

  12. Cafe Lehmann Avatar
    Cafe Lehmann

    Great feature!
    cfevangelists = [{firstname="Ben", lastname="Forta"}, {firstname="Cafe", lastname="Lehmann"}]
    http://www.cafe-lehmann.de – they make good cake!

  13. David Boyer Avatar
    David Boyer

    This is great news, I just hope plans don’t change. I currently work around this with two functions of my own called Struct and array.
    Array(1, 2, array(‘a’, ‘b’, ‘c’), 3);
    Struct(this = ‘that’, foo = Struct(bars = Array(1, 4, 7)));
    They do the trick for now but I’d love to use the new methods, probably be quicker too.
    I second Hansjoerg with passing them directly to a named argument in a component / function.
    Speaking of which, any ideas if the updater is planned to fix named arguments for scoped functions? For example, foo(bar = ‘test’) works but variables.foo(bar = ‘test’) throws an error, same goes for whatever scope I copy the function too. I did submit it via some old bug page link but never heard anything back.

  14. tony petruzzi Avatar
    tony petruzzi

    any word if the updater will fix the bug described by Hansjoerg?

Leave a Reply