W3C home > Mailing lists > Public > public-webapi@w3.org > December 2007

Re: [Bindings] stringify

From: liorean <liorean@gmail.com>
Date: Tue, 25 Dec 2007 11:19:23 +0100
Message-ID: <cee13aa30712250219t5ea5f013k44f756f6f04061a3@mail.gmail.com>
To: "Web APIs WG (public)" <public-webapi@w3.org>

On 24/12/2007, Anne van Kesteren <annevk@opera.com> wrote:
> Maybe the draft already says something about this, but I couldn't find it.
> I think it would be good if there was a way in the IDL to say what an
> object stringifies to. The Window object becomes "[object Window]" and
> Location stringifies to its href attribute value. The tricky part here is
> objects implementing multiple interfaces, such as Document and
> DocumentSelector, but in those cases the specification editors should
> probably ensure there are no strange things.

I've been meaning to address this (or a related issue, anyway) in a
mail to both ES4-discuss and to WebAPI.
Wouldn't it be best to specify which interface is the main interface
for objects? ECMAScript assumes a strict single inheritance scheme.

> Jim Ley wrote:
> > Could you describe the use cases for defining this at all?

On 24/12/2007, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> Interoperability.  Specifying that Window stringifies to [object Window]
> is probably unnecessary (and not true in all UAs anyway).  But
> specifying that, Location stringifies to its .href property is needed
> (and is interoperably implemented).

Well, the ECMAScript spec already specifies how objects stringify. If
the [[Class]] internal attribute of the implementing object contains
the value "Window", then the correct stringification would be "[object
Window]". Which is probably the best solution for Window. Location
probably needs to override toString.
-- 
David "liorean" Andersson
Received on Tuesday, 25 December 2007 10:19:35 GMT

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