Saturday 23 November 2013

HTML 5 and namespaces

The decision not to include support for namespaces in HTML 5 can only be described as a disaster, especially in the light of the forthcoming Web Components technology. How are we supposed to distinguish novel tag elements created in different libraries? It's going to be vendor prefixes all over again, a real trip back to the stone age.

Saturday 16 November 2013

A nice Javascript idiom

At least, I think it's cute — type-purists would probably scream in horror. To my mind, it's illustrative in a very small way of the recent explosion in understanding of and familiarity with Javascript's amazing flexibility; it's gone from being despised s a mere web page scripting language to being recognised as a powerful and elegant multi-paradigm language with functional and metaprogramming elements in very short order.

Anyhoo, this is how to write a single function that not only acts as both a member getter and setter, but also allows you to chain setter calls:


radius: function(newRadius) {
if (arguments.length === 0) {
return this.r;
}
this.r = newRadius;
return this;
}

ECB ready to print, Germany ready to scream

An interesting article from Ambrose Evans-Pritchard in the Telegraph: ECB ready to print, Germany ready to scream.

I do so love it when one of my predictions is borne out.

Tuesday 12 November 2013

Today's depressing error message

Courtesy of Google Charts:

Error: Type mismatch. Value 269.40 does not match type number in column index 1

The data comes from an original Yahoo data feed, converted from CSV through Yahoo's own yahooapis.com to a JSON feed, and so is in a textual format. But that's not supposed to matter with Javascript -- if it looks like a number, it's supposed to act like a number.

Still, worthwhile perhaps trying explicitly converting numerics to numbers before putting them into the data table that backs the chart, just in case. Possibly somewhere in Google's code something is doing a regex on numerics, and possibly my code to extract from Yahoo's convoluted data feed has missed an extra space or something (not likely!).