Showing posts with label Closure. Show all posts
Showing posts with label Closure. Show all posts

Thursday 2 January 2014

A quick survey about tags & script in the same statement

Here's a quick survey for y'all: '"Closure" confusion'.


As one of my respondents observed... the question has nothing to do with "closure" but is entirely relating to anonymous functions / function expressions. For better or for worse, people use the term "closure" incorrectly to describe these things. A function expression implements closure, but there's no such thing as "a closure" (no matter how many people will it to be the case). Closure is not a countable noun; it's a concept. I am fully aware of this, I was just mocking Adobe's usage of the term. Hence me referring to it in quotes.

The narrative for the survey is as follows:

This is a quick survey to determine how clear some suggested CFML syntax would be. It relates to the bug tracker issue described here:

The contention is that the suggested syntax would be confusing for CFML developers.

I am just wanting to gauge your thoughts on this.

I will collate the responses after I have received a reasonable number of them, and post them on my blog.


Sunday 8 December 2013

CFML: For the sake of completeness: createLocalisedDayOfWeekAsInteger(): a closure approach

A coupla days ago I continued my TDD / unit testing series with an article "Unit Testing / TDD - refactoring existing code". This engendered a few comments, none of which paid any attention to the intent article, instead focused on something pretty much irrelevant to what I was discussing. This engendered this reaction from me:

Oh how I love my readership sometimes. But, actually, the comments got me thinking...

That article covered the approval process for CFLib of a function dayOfWeekAsInteger(), which is the reverse of dayOfWeekAsString(): it takes a string (in English only), and returns which day of the week that corresponds to, starting with Sunday as the first day. Why does it start on Sunday instead of Monday (as per ISO 8601)? Because it's the inverse of dayOfWeekAsString(), and that's how that does it. Is that right? Well: no. Is that relevant to either this UDF or the blog article? Also: no.

However James's suggestion for how Simon could rewrite his function to suit James's requirements (James: write your own functions if you want them different from how others have implemented them!) did get me thinking about how to do it. A thought popped into my head that one could leverage closure to create a function which was specific to a given locale. This might not be exactly what James wants, but it was what I decided to look into, because it's slightly interesting, and covers a feature of closure I've not covered anywhere on this blog yet. So it interests me.

Sunday 24 November 2013

Can a function expression circumvent closure?

I'm stumped. I "need" to have a function expression that can reference the context it's being executed in as well as the context it was declared in. And I can't work out how. I suspect this is because of one of two reasons:
  1. I'm thick;
  2. it's not possible.
(I am not suggesting those are mutually exclusive options).

Monday 7 October 2013

"Not worth the effort" again, from the Adobe ColdFusion team

Andrew Scott brought this one to my attention. It's what seems to be another example of Adobe finding the "too hard basket" being more convenient that rolling up one's sleeves and actually doing one's job properly.

Wednesday 26 September 2012

Callbacks, function expressions, IIFEs, delegates (OK, and closure I s'pose)

Right, so after a coupla delays, here's the article I threatened you with that's not about closure. Obviously it actually is going to mention closure, but consigned to an afterthought (where, IMO, they kinda belong).

So what is it about? Well it's about a technique that's been possible in ColdFusion since CF5 but is not obvious so is under-utilised, a handy new syntactical construct that was added in CF10, and another one that should have been in CF10 but isn't, something for CF11... and a footnote.