A little geek entertainment...

8 views
Skip to first unread message

John J Barton

unread,
Oct 8, 2009, 6:52:27 PM10/8/09
to Firebug

Wilson Lee

unread,
Oct 8, 2009, 10:21:27 PM10/8/09
to Firebug
Ah hah. A Spidermonkey- and Rhino-specific little nugget.

- kourge

Wladimir Palant

unread,
Oct 9, 2009, 5:20:41 AM10/9/09
to Firebug
You are trying to use E4X syntax on something that isn't an XML object
- http://en.wikipedia.org/wiki/ECMAScript_for_XML

Correct use of that syntax:

var data = <root><value a="1">foo</value><value a="1">bar</
value><value a="2">bas</value></root>;
alert(data.value.(@a == 1));

"bar" is also a valid filter but it is a useless one - it is the
equivalent of true.

johnjbarton

unread,
Oct 9, 2009, 11:01:32 AM10/9/09
to Firebug


On Oct 9, 2:20 am, Wladimir Palant <trev....@adblockplus.org> wrote:
> You are trying to use E4X syntax on something that isn't an XML object
> -http://en.wikipedia.org/wiki/ECMAScript_for_XML
>
> Correct use of that syntax:
>
> var data = <root><value a="1">foo</value><value a="1">bar</
> value><value a="2">bas</value></root>;
> alert(data.value.(@a == 1));
>
> "bar" is also a valid filter but it is a useless one - it is the
> equivalent of true.

Yes, more evidence that E4X is a bug. Embedding non-core features in
to Javascript by cute syntax degrades the language.

Here is the back story. I got the error message, which included by
the way, a complete copy of the web page (yes, in the error message
text!). I had no idea why or where this came from, in part because the
line number for the error message was at the end of the error message,
many hundreds of characters off screen.

When I did find the line number I saw what had happened. Some time ago
I had been searching through the source for "getScriptAnalyzer". I
must have ended the search on a line like
var f = sourceBox.getScriptAnalyzer(script);
with the method name selected. I that point I got distracted and
sometime later hit the keyboard, deleting the method name:
var f = sourceBox.(script);
Before cutesy E4X syntax corruption, this line would have been a
simple syntax error. Now this line becomes a bizarre error message
(but could also have been a valid line that did something). For
reasons like this E4X is not an architectural building block, layering
on the foundation of the JS language to enhance it for a subcategory
of users. Instead it is a corruption, infiltration of the language
forcing everyone to deal with the XML mistake.

Or I need to be more careful typing, ;-)

jjb

jjb
Reply all
Reply to author
Forward
0 new messages