W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2013

Re: Figuring out easier readonly interfaces

From: Mark S. Miller <erights@google.com>
Date: Thu, 17 Oct 2013 19:23:24 -0700
Message-ID: <CABHxS9jQVQGmJp8h=XLcQ63w+Kav8kkBgL62yQSU6QEfnLU6KQ@mail.gmail.com>
To: Simon Pieters <simonp@opera.com>
Cc: James Graham <james@hoppipolla.co.uk>, Domenic Denicola <domenic@domenicdenicola.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Thu, Oct 17, 2013 at 4:41 PM, Simon Pieters <simonp@opera.com> wrote:

> On Fri, 18 Oct 2013 01:12:23 +0200, Mark S. Miller <erights@google.com>
> wrote:
>  I think renaming doesn't really do much to ensure that the above situation
>>> doesn't materialize.
>> if (rect instanceof DOMRectReadable) {
>>   // ok, it's readable, so one can read rect
>>   untrustedCode.****doSomethingWithRect(rect);
>>   // I can assume that rect may have been read.
>> }
>> Yes, there is still a possibility of confusion: rect being readable does
>> not imply that it is read-only, but one might still misread the correct
>> comments above as "I can assume that rect may have *only* been read." But
>> at least this is a misreading, and one can learn not to read in more than
>> the interface is claiming. Of course, such bugs will happen anyway, but
>> this misreading would now be on a par with other normal bugs, such as
>> confusing "if" with "iff".
> What I mean is, people on the Web write code making completely bogus
> assumptions (and no commenting) all the time such that it's hopeless trying
> to guide them by the name of an interface.
>  If we want to avoid it, it's better to have completely separated
>>> interfaces.
>> Care to make a concrete proposal?
> https://dvcs.w3.org/hg/csswg/**raw-file/748437d8a1dc/cssom-**
> view/Overview.html#domrect<https://dvcs.w3.org/hg/csswg/raw-file/748437d8a1dc/cssom-view/Overview.html#domrect>
> or
> https://dvcs.w3.org/hg/csswg/**raw-file/3c529183812b/cssom-**
> view/Overview.html#domrect<https://dvcs.w3.org/hg/csswg/raw-file/3c529183812b/cssom-view/Overview.html#domrect>
> A drawback here is that if one wants to check if an object is a "rect",
> you need to do two instanceof checks.

For the webidl at the first link, aren't you naming the common supertype
AbstractRect? That would be fine with me.

For both, it seems like DOMRectAny is also a common supertype, specified as
a union type rather than by "implements". I don't love the name but it is
non-objectionable. So only the second design needs two instanceof checks?
For the first, you can just "... instanceof AbstractRect"?

Aren't you also missing a subtype for an immutable DOMRect?

> --
> Simon Pieters
> Opera Software

Received on Friday, 18 October 2013 02:23:52 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:18 UTC