Showing posts with label Railo. Show all posts
Showing posts with label Railo. Show all posts

Wednesday 16 April 2014

Odd behaviour with struct keys with dots in their names

G'day:
I've been looking at this one due to an interesting question on Stack Overflow: "Confusion in dynamic variable access in ColdFusion". I could not immediately see what the problem was, and it's taken me a coupla hours to work out what's going on.

Saturday 12 April 2014

Bugs in iterator functions in both Railo and ColdFusion

G'day:
I decided to "do my bit" for the cfbackport project, and am looking at implementing the new collection iteration functions for older versions of ColdFusion. I'm aiming for CMFX6.0 onwards, but am having to guess at some of the language restrictions as I'm on my back-up laptop and only have CF10 & 11 to test with.

Friday 11 April 2014

Railo 4.2.0.007 is out: more new iteration methods

G'day:
Micha posted on the Railo Google Group the other day "(Last) Railo beta release (4.2.0.007)". You can get this via the in-admin updater if you're set to use the "Development releases (Bleeding Edge)" update channel.

Staying true to form, the upgrade process is seamless, and it also offers a bunch of excellent new stuff, as well as bug fixes. This is definitely the way CFML should be heading... not waiting around two years between features, as we have been with ColdFusion.

There's a swag of new stuff, but I'm just gonna focus on the added iteration methods: for queries and lists.

ColdFusion has had some list iteration functions since ColdFusion 10, and adds more in ColdFusion 11. I discuss them in "ColdFusion 11: .map() and .reduce()". Railo hadn't implemented them, I think because they - somewhat dogmatically - don't consider lists to be a "type", therefore only consider string functions to be appropriate for strings. This is slightly specious IMO because Railo does have all the other list functions, after all. Anyway, they've added them now.

Here's example usage of the list-iteration member functions: .each(), .filter(), .every(), .some(), .map(), .reduce(). They have not implemented a list-sorting iteration function, for some reason. This code is also on GitHub: list.cfm.

rainbow = "whero,karaka,kowhai,kakariki,kikorangi,tawatawa,mawhero"

"first,second".each(function(){
    dump(arguments)
})

rainbow.each(function(element,index,list){
    echo("#index#/#listLen(list)#: #element#<br>")
})

Saturday 5 April 2014

I am one step closer to being unshackled from ColdFusion

G'day:
Note that that is ColdFusion, not CFML. I'm still onboard with CFML, and that's not likely to change in the mid-term. Today I switched all my hosted code from ColdFusion to Railo. So now my only connection to the Adobe product is my day job.

Wednesday 2 April 2014

Survey results: lists in CFML, and the naming of list member functions

G'day:
I didn't quite get 50 results for this survey, but so be it. It wasn't a terribly interesting one, granted. So, what do people think about lists, list functions, and what the approach to the naming of list member functions should be?

The subject line of the survey was:
ColdFusion 11 and Railo 4 have added "member functions" to CFML, so one can call a method on an object, rather than pass an object to a function. ColdFusion has implemented list functions as member functions of a string, and in the process have blurred the distinction between what's a list function and what's a string function. There is conversation about this on the Railo Google Group, and this has lead me to wonder what the community participants think about Adobe's approach here.
There were five questions.

Sunday 30 March 2014

Railo: I've got to the bottom of that code I asked you to test for me

G'day:
Thanks to everyone who helped out with my challenge in this article: "Railo: help me replicate a bug I'm seeing on one of my machines". I think the reason I was seeing the difference in behaviour is twofold:
  1. I'm a dropkick;
  2. Railo's setting "Local scope mode" (which I can't find docs to link to [grumble], so I'll need to explain it).
The reason why I suspect I'm a dropkick is that I think this is all down to my machine at work having "local scope mode" set to "modern", whereas every other instance I have been looking at is set to "classic". I do not recall switching my work machine to use this setting (and I'll be switching it off as soon as I sit down at it on Monday), but it seems like this is what the difference is.

Thanks to Gert for pointing me in the direction of the various Railo "make Railo work differently from ColdFusion" settings that Railo has.

Railo: it already supports separating parameters from the SQL string

G'day:
This is a very quick  update to my previous article: "Query.cfc / queryExecute() have a good feature cfquery lacks". Railo already supports this (although it's apparently undocumented?).

Whilst raising the ticket for ColdFusion, I found an already-raised (and resolved) ticket in the Railo bugbase: RAILO-2203.

Micha has added a comment to the bottom of it: "added as hidden feature", but it is there and it does work:

<cfset params = [
    {value=URL.low},
    {value=URL.high}
]>
<cfquery name="numbersViaPositionalParams" params="#params#">
    SELECT  en AS english, mi AS maori
    FROM    colours
    WHERE   id BETWEEN ? AND ?
</cfquery>

<cfset params = {
    low=URL.low,
    high=URL.high
}>
<cfquery name="numbersViaNamedParams" params="#params#">
    SELECT  en AS english, mi AS maori
    FROM    colours
    WHERE   id BETWEEN :low AND :high
</cfquery>

Cool! Go Railo!

I shall update the ticket I raised with Adobe to encourage them to follow Railo's lead here.

--
Adam

Saturday 29 March 2014

Railo: help me replicate a bug I'm seeing on one of my machines

G'day:
A few days back I raised a bug with Railo - "Bug with scoping inside iterator functions" (RAILO-3000) - which only happens on one of my Railo installs (out of six installs, on four different machines). Micha can't replicate it either. I'm trying to get to the bottom of what's going on, and what's different about my install.

Update:

I've got to the bottom of this. See "Railo: I've got to the bottom of that code I asked you to test for me"


Here's the code:

Friday 28 March 2014

Survey: lists in CFML, and the naming of list member functions

G'day:
There's a conversation brewing on the Railo Google Group regarding string / list member functions ("String member functions and list functions"), and this touches on ColdFusion's approach to these.

TL;DR: the survey is here: "List function support as member functions in CFML"

Update:

The survey is now closed. Results are here.


The question being asked on the Railo forum is whether to bother supporting list member functions in Railo at all. And as an aside to this, some lack of uniformity in how ColdFusion 11 has implemented these has cropped-up.

Firstly, I'll "go on record" as saying that I think having a specific concept as a "list" as a (pseudo) data type in CFML is a bit rubbish. Strings aren't intended for implementing data collections, and aren't very good at doing it, so - IMO - it was a poor idea to facilitate it. If Railo and ColdFusion deprecated the concept of lists entirely, the (CFML) world would be a better place.

That said, they are in the language as a concept, so we have to acknowledge this I guess.

Adobe have added list member functions to CFML in ColdFusion 11.  Here's a table of their implementation ("Supported List member functions"):

Tuesday 25 March 2014

myArray.each()... extending the array whilst iterating..?

G'day:
I dunno what to think about some behaviour I'm seeing when iterating over an array with the .each() method.

Consider (but do not run!) this code:

numbers = ["one","two","three","four"];
numbers.each(function(value,index){
    if (value=="one") {
        numbers.append("five");
    }
    writeOutput("Index: #index#; value: #value#<br>");
});
writeDump(var=numbers);


Railo adds more iteration functions: *some() and *every()

G'day:
Starting with ColdFusion 10 and some-version-or-other of Railo 4 (Railo moves so quickly I can't keep track of when features are added), CFML has been adding collection iteration functions which leverage callback functions to provided the functionality for each iteration. Examples are arraySort(), listFilter(), structEach() (the coverage in each CFML dialect for each collection data type is not fully comprehensive nor do they necessarily both implement the same functions the other does). ColdFusion added in map and reduce functions (detailed in my article "ColdFusion 11: .map() and .reduce()"), now Railo has added those in, and gone one better: now adding some() and every() functionality too. In this article I'll recap each of the sort / filter / each / map / reduce functionalities, and have a look at some() and every().This is a Railo-centric article. The code will not run on ColdFusion without modification.

Sunday 23 March 2014

CFML: Built-in functions, UDFs, methods, and function expressions... with the same name

G'day:
I have no idea what I'm playing at. It's 9pm on Saturday night and I am in a downtown Galway ("Galway, Ireland", for you Americans... there's probably a Galway in TX, MN, CA as well ;-) pub, which was nice and quiet this afternoon and good for a quiet drink and some blog research. Now it's a full on Saturday night and everyone else is just partying and I'm still typing. The alternative is sitting here by myself and drinking, looking like... I'm sitting here by myself and drinking (and it'd not be the first time. Even today!). I guess at least I would not be the only person in the place writing a blog article about CFML.

Right, so today's efforts started with the intention of looking at some new methods in Railo: .some(), .every() (there's no docs for these yet - that I can find - but there is a Jira ticket: Add closure functions ArrayMap, ArrayReduce, ArrayEvery, ArraySome functions), and rounding out at look at any other CFML iteration functions I'd not looked at yet. I've looked at some previously from a ColdFusion perspective: "ColdFusion 11: .map() and .reduce()".

But then an interesting discussion came up on the Railo Google Group and the function map() which has been added to the latest Railo BER, which breaks WireBox: "Wirebox breaking on latest Railo patch 4.2.0.006", and this absorbed me for the rest of the afternoon and evening, thinking about it, wittering on on the forum, and testing some code. There's a few concepts discussed on the thread, and it's worth reading in its entirety.

Friday 7 March 2014

Railo: small new feature I didn't catch making it into the language

G'day:
This is a minor but handy feature in Railo 4.2 that Micha just gave me a heads-up on. One can treat a string as an array:

s = "G'day world";
for (i=1; i <= s.length(); i++){
    writeOutput(s[i]);
}
writeOutput("<hr>");

charAfterApostrophe = s[find("'", s)+1];
writeOutput("charAfterApostrophe: #charAfterApostrophe#");

Output:

G'day world

charAfterApostrophe: d


Not very exciting, but makes sense, and saves a call to mid() if needing to extract characters from the string.

--
Adam

Thursday 6 March 2014

Wednesday 5 March 2014

CFML is dying. Let's drop it off at Dignitas

G'day:
Yes. It's another "CFML is dying" article. We haven't had one for a while. Note that this is not "ColdFusion is dying", this is CFML in general.

TBH: the headline is slightly tongue-in-cheek, and designed to garner outraged click-throughs whilst the Daily Mail readers amongst us search for the "Comment on this article" button so they can display their mouth-froth to everyone.

This article actually isn't about CFML. And that's the point.

Monday 24 February 2014

Breaking out of an each() loop

G'day:
I'm just soliciting opinions here. I'll raise a ticket for it anyhow, but let's see what people think.

Saturday 22 February 2014

CFML: Feature toggling for both Railo(/Lucee) and ColdFusion

G'day:
I'm just drawing attention to part of the bottom line of my previous article ("Expressions and operators and doing weird shit"), as I think it's a significant feature request for both Railo and ColdFusion.

I've suggested both Railo (RAILO-2926) and ColdFusion (3712059) should implement a feature toggling system. This would resolve issues both platforms have with cross-compatibility and backwards-compatibility.

There are a few things recently that I've raised with both companies and the response has been "be that as it may... we can't do it due to backwards compat" (to be fair to Railo they are far less emphatic about this, and usually consider how else to approach things; in Adobe's case it's just their favourite mantra when they don't feel like fixing something, I think).

The degree of validity of the compatibility issues is one thing, but it is a real consideration. However I want Adobe to stop wallowing in the past, and I want Railo to not have to wallow alongside them for the sake of cross-compatibility. Plus there's some own-goal issues with some Railo code too.

What I think both need is a feature toggling system which can be applied to a feature meaning that by default a new backwards-incompat fix will work for everyone for whom there isn't a backwards compat issue (which, let's face it, will generally be most people, for any given issue). However to preserve the sanity of people whose code is impacted by these fixes and just toggle them off until they get around to updating their code to not rely on broken CFML behaviour.

I'm so fed up with some of the inertia we're seeing in CFML that something needs to be done. And especially for ColdFusion... now's the time, given we're in the dev phase of ColdFusion 11.

As always... thoughts / comments?

I think I need to do one more gripe about integers, but then I can crack on with looking at new stuff in ColdFusion 11. I'm still finding good stuff! :-)

--
Adam

CFML: Expressions and operators and doing weird s***

G'day:
I want to just return to the topic I touched on here briefly the other day in the article "ColdFusion 11: good stuff", and discussed more thoroughly on the Railo Google Group as "Probable bug in null-coalescing operator". I have moved my opinion here from "probable bug" to "definite bug". And the buggy behaviour relating to this extends further, and into both Railo and ColdFusion.

My contention is that Railo have implemented the null-coalescing operator (tritely referred to as the "Elvis operator" by some. Spare me) slightly incorrectly, as it confuses the notions of "null" and "non-existent" which are two distinct concepts. Also, in implementing this "non-existence-coalescing operator", it's done some rather fishy things in the process.

All of this has also now found its way into ColdFusion 11, unfortunately.

Wednesday 19 February 2014

TestBox, BDD-style tests, Railo member functions and bugs therein

G'day:
One of the promised features of ColdFusion 11 is to bring "member functions" to ColdFusion's inbuilt data types. Railo's already had a good go at doing this, and has reasonably good coverage. See "Member Functions" for details.

One concern I have is whether ColdFusion 11 will implement these the same way as Railo already has. I mean... they should do, there's not much wriggle room, but who knows. If there's a way to do it wrong, I'm sure Adobe can find it. With that in mind, I want to be able to run through some regression/transgression tests on both systems once ColdFusion 11 goes beta, so in prep for that, today I knocked out some unit tests for all the struct member functions.

What I did is to go into the ColdFusion 10 docs, go to the "Structure functions" section (to remind me what all the functions were), and write unit tests for the whole lot. I used the ColdFusion docs rather than the Railo ones because the CF10 docs are more comprehensive than Railo's (this is an indictment of Railo's docs, not a recommendation for the ColdFusion ones, btw!), plus I wanted to make sure I covered any functions Railo might have overlooked.

To make this more interesting (because, let's face it, it's not an interesting task; either to undertake, write up, or for you to read about!), I decided to have a look at TestBox's BDD-inspired testing syntax. The short version of this side of things is that I rather like this new syntax.  I don't think it's got anything to do with BDD (which is an approach to documentation and test design, not a syntax model), but it's interesting anyhow.

Anyway, stand-by for a raft of code (there's a Gist of this too: Struct.cfc):