W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2008

Re: [whatwg] WebIDL and HTML5

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 28 Aug 2008 09:27:17 -0400
Message-ID: <48B6A7B5.7000501@mit.edu>
To: Garrett Smith <dhtmlkitchen@gmail.com>
CC: Web Applications Working Group WG <public-webapps@w3.org>

Garrett Smith wrote:
>> Any Java method that takes a String can have null passed to it.
> 
> Yes, and this is true for any reference type, not only String.

Yep.  Point is, DOMString is defined as a reference type.

> Are you concerned with what can be passed to a method, or what is a String?

The former, of course.  The latter really doesn't matter to me very much 
as the implementor of a DOM binding or of a DOM implementation.  All 
that matters is:

1)  What possible inputs could come in?
2)  What should I do with them?

I don't much care about the data types in ECMAScript apart from their 
impact on those two points.

> In EcmaScript, well, didn't we have a demo here just a few hours ago?
> I included four primitives in the demo: null, undefined, number,
> string. I forgot boolean. Not only can you pass anything

That's a function of the ECMAScript-to-DOM-implementation bindings, not 
of the DOM spec itself, for what it's worth.

Put per DOM spec the DOM implementation MUST be able to tell null and 
any given string value apart when the argument is a DOMString, since 
DOMString supports null semantics.

> However, if a method takes a domstring, why would anyone want to pass
> null?

I have no idea, but the DOM spec requires that my DOM implementation 
handle it.  I honestly can't guess why someone would "want" to do all 
sorts of things with web technologies, yet people do them all the time. 
  I suspect a lot of them do it by copy-pasting other code, lossily.

> Wouldn't passing null seem to be a mistake? Just don't do it!

I don't care what you do on your end, honestly.  I need to make my end 
work with all possible inputs.  I can't just rely on authors not passing 
null, because fundamentally I don't trust authors.  Given any action 
that can be performed, they will perform it.  And the spec needs to be 
written in such a way that behavior is defined in all cases, and UAs 
then need to implement the spec.  We're not there now, but that's the goal.

> Null is not a String. Not in Java; not in EcmaScript. In both
> languages, the Null type has no Name and has only one value - null.

The only question is what happens when null is passed to a method taking 
DOMString.  The semantic question of "what is a String" is not relevant 
to that issue.

> Unlike Java, EcmaScript offers no compiler checks for *anything*.

That's not true, actually.  There are plenty of compiler checks in a 
typical modern ECMAScript implementation.  They're just not type-checks.

-Boris
Received on Thursday, 28 August 2008 13:28:04 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:27 GMT