W3C home > Mailing lists > Public > public-appformats@w3.org > January 2007

Re: [XBL] ECMAScript Syntax

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 5 Jan 2007 23:50:43 +0000 (UTC)
To: Cyril Concolato <cyril.concolato@enst.fr>, Marcos Caceres <m.caceres@qut.edu.au>, Cameron McCormack <cam@mcc.id.au>
Cc: "WAF WG (public)" <public-appformats@w3.org>
Message-ID: <Pine.LNX.4.62.0701052346140.22379@dhalsim.dreamhost.com>

On Thu, 7 Dec 2006, Cyril Concolato wrote:
>
> Is the ECMAScript syntax in the 'implementation' element free like:
>
> <implementation>
>   foo = 1;
> </implementation>
> 
> or shall/should it obey some specific ECMAScript syntax (as all the 
> examples in the specification suggest), i.e. start with ({, contain only 
> fonction declarations, and end with }).

The spec requires that whatever is executed evaluate to an object. So I 
guess you could do something like:

   <implementation>
     var x = new Object();
     x.foo = 1;
     x;
   </implementation>


> If the syntax is free, please say so in the specification. If not, 
> please give link to specifics constructs allowed from the ECMAScript 
> specification. This would satisfy me.

This is already covered by section 5.4 as far as I can tell. 
(Specifically, 5.4.1.)


On Fri, 8 Dec 2006, Marcos Caceres wrote:
>
> Cyril raises an interesting point there regarding implementations and 
> how they should be handled by scripting langauges within the context of 
> XBL. For ECMAScript, it might be nice to write the constructor without 
> using the old ({ ... }). Can I do the following?:
> 
> <implemenation>
> //where "this" is the scope of this implementation
> this.x = 1234;
> this._y = 4321;
> this.funky = function(){...}
> this._helper = {( functionName: function() { return true; })}
> </implemenation>

"this" in this context would be "window", so that wouldn't work. But 
things like the example above would, as far as I can tell. (I'm no JS 
expert.)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 5 January 2007 23:50:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:10:21 GMT