This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 154180 - E4X function:: notation causes error in JavaScript parser
Summary: E4X function:: notation causes error in JavaScript parser
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-30 22:19 UTC by brettz9
Modified: 2014-01-16 10:28 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brettz9 2008-11-30 22:19:14 UTC
Although I have not found any documentation for this "function::" E4X notation, others have referred to it on the net,
and it works in Mozilla. However, using it in Netbeans (in a plain JavaScript file) gives an error:

var a = foo.(function::attribute('var') == 'bar');  // Gives "missing ( before function parameters"
Comment 1 Torbjorn Norbye 2008-12-01 01:23:09 UTC
It's hard to know what to do about this since there's no spec for it. We just got JavaScript 1.7 support (see http://blogs.sun.com/tor/entry/netbeans_screenshot_of_the_week4 ) but I don't think this is valid JavaScript 1.7

I'm speculating that this perhaps is related to the namespace stuff in JavaScript 2.0?
( http://www.mozilla.org/js/language/js20-2002-04/index.html )
but it's hard to say more without more knowledge of what this code is supposed to be doing etc.

Support for languages beyond JavaScript 1.8 would be an enhancement so changing issue type from defect to enhancement.

If you come across more information about this construct and can attach it here that would help.


Comment 2 brettz9 2008-12-01 04:59:42 UTC
Thinking about it some more, I think it is likely that the "function::" notation itself is some kind of JS namespacing,
as you suggest. Since this is used within a filter, that presumably avoids a potential JavaScript conflict which
something like the following might have:

var a = foo.(attribute('var') == 'bar');

As far as the particular use here, it works basically like foo.attribute('var'), but within a filter--or as would
foo.@var if the latter were legal when using a reserved keyword (actually, I'm not clear that the latter is not legal
because while all of the tutorials, etc. I've seen mention that the use of the .attribute() notation is to avoid using
reserved keywords, the E4X spec itself doesn't seem to mention that reserved keywords are not allowed, and Mozilla
itself allows it).

The "function::" notation also is necessary within the filter to avoid errors when a reference is made to an item or
attribute in the filter which does not exist at all on one of the filtered items. See
https://bugzilla.mozilla.org/show_bug.cgi?id=336355
Comment 3 brettz9 2009-01-04 09:50:27 UTC
I found a source note where Brendan Eich (JavaScript creator) indicates regarding this feature that he had "prototyped
this in SpiderMonkey":
http://groups.google.com/group/netscape.public.mozilla.jseng/browse_thread/thread/b99b718927d06901/0803567b41f3e191?lnk=gst&q=%22prototyped+this%22#0803567b41f3e191
.

This feature is very seriously needed by anyone using E4X (at least Mozilla which makes it available) since filters
(which work similar to XPath expressions) are otherwise practically useless.