AdobeStock_455007340

ColdFusion And JavaScript Like Operators

This one was met with a round of applause last night in Dallas. In Scorpio you can now use the following in CFML expressions:
++ -- % += -= *= /= %= && || !
In addition, in you can use the following operators:
== != >=

19 responses to “ColdFusion And JavaScript Like Operators”

  1. Steven Van Gemert Avatar
    Steven Van Gemert

    I may have clapped the loudest for this, lol. Love the idea, finally a ++, and a % for CF!
    And bravo for figuring out the validation nightmare that must have been "if(a<b) || (a>c)". It sure looks like it should validate as a tag, but grats for figuring it out and including it! Well done!
    Do we call it CF++ now? 🙂

  2. Thomas Rühl Avatar
    Thomas Rühl

    Yay, finally! Good one 🙂
    Ben, say are there by any chance plans to give developers the oppertunity to write cfc’s *completely* on a script basis, too? Like defining a component with a class (~component) keyword rather than using the tag syntay? Also, will there be mechanisms like interfaces or abstract classes in CF++? 😉
    Cheers, Thomas

  3. Ben Forta Avatar
    Ben Forta

    Give them an inch and they want a mile. 😉
    Thomas, interfaces are in Scorpio, but no plans for for class creation in script. And, without starting a big debate on the subject, I would be very opposed to this idea myself. If you want components defined as classes, well, use Java, it does it really well. But, ya never know.
    — Ben

  4. KEVIN BENORE Avatar
    KEVIN BENORE

    Great to have you in DFW! A question came to mind about the CFIMAGE tag. Currently we have an image server which we use some of the same functionality you talked about with CFIMAGE. Will there be any caching available of images (or is that me just dreaming to big)? Can you manipulate the DPI? We keep hi-res JPEGs (300 dpi) for print and then our image server renders them as 72 dpi for display.
    I am so very, very excited and can’t wait for the release of CF8. Thanks for your wonderful presentation last night!

  5. Kevin Avatar
    Kevin

    That is awesome, I’m very excited about the new operators. I have a question though. I’ve been told IIF is very slow. Is the following going to work?
    a = (b == true) ? c : d;

  6. Steven Van Gemert Avatar
    Steven Van Gemert

    Ben said:
    Give them an inch and they want a mile.
    True Ben, but please realize that we’re REALLY grateful for the inch! 🙂
    Steven

  7. Thomas Rühl Avatar
    Thomas Rühl

    Steven said:
    True Ben, but please realize that we’re REALLY grateful for the inch! 🙂
    hell, we are 😀
    Cheers, Thomas

  8. Ben Nadel Avatar
    Ben Nadel

    #ERROR!

  9. hibiscusroto Avatar
    hibiscusroto

    that’s pretty cool!

  10. Joshua Curtiss Avatar
    Joshua Curtiss

    This is AWESOME!!! It is so irritating not having the incremental operators. That will be awesome. It only makes sense, getting closer to ECMAScript.
    Now, to go for the mile.. 😉 I agree with Kevin that it would be awesome to have support for ? as in:
    a = (b == true) ? c : d;

  11. Michael Dinowitz Avatar
    Michael Dinowitz

    IIF() was slower than CFIF in earlier versions of ColdFusion but in MX they compile down to the exact same code.

  12. Steven Ross Avatar
    Steven Ross

    a = (b == true) ? c : d; is called a ternary operator. 😉

  13. Rick Root Avatar
    Rick Root

    pretty awesome Ben!
    I hate doing
    <cfset foo = foo + 1>
    Now I can do
    <cfset foo++>
    Now if you can add a &= operator.
    <cfset foo = foo & "some string">
    becomes
    <cfset foo &= "some string">

  14. Matt Williams Avatar
    Matt Williams

    Rick,
    I’m willing to be that with CF being dynamic and all that this will work for you:
    <cfset foo += "some string" />

  15. shuns Avatar
    shuns

    Finnnnnnnnnnnally! This is a feature that has been missing for a long time. 😉

  16. Chris Phillips Avatar
    Chris Phillips

    Rick,
    Not sure why, it’s not in the list.
    But, you can do &= for string concatination.
    (The tour just came through PDX on Monday).
    Awsome stuff.
    I’m excited to be a CF developer.

  17. Ben Forta Avatar
    Ben Forta

    >> Can you manipulate the DPI? We keep hi-res JPEGs (300 dpi)
    >>for print and then our image server renders them as 72 dpi for display.
    Kevin, no, this is not supported at this time.
    — Ben

  18. Dustin Avatar
    Dustin

    One thing I’ve missed is the ability to effectively loop a query in script. Something like this would be awesome:
    forin(query||struct[,item]){}

  19. sal Avatar
    sal

    sooo! wicked! definitely past due

Leave a Reply