Re: Figuring out easier readonly interfaces

On Thu, Oct 17, 2013 at 3:48 PM, Simon Pieters <simonp@opera.com> wrote:

> On Thu, 17 Oct 2013 22:45:50 +0200, Domenic Denicola <
> domenic@domenicdenicola.com> wrote:
>
>  I think some example code helps this discussion. From what I can tell,
>> Mark is concerned about code like this:
>>
>> ```js
>> if (rect instanceof DOMRectReadOnly) {
>>   // ok, it's read only, so only its creator can write it
>>   untrustedCode.**doSomethingWithRect(rect);
>>   // I can assume that rect has not change.
>> }
>> ```
>>
>
> 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".

It would be a whole 'nother level of programmer hostility to ask
programmers to learn: "When it says 'DOMRectReadOnly', ignore the 'Only'
part. It is just wrong."



on·ly
ˈōnlē/
*adverb*
**

   1. *1*.
   and no one or nothing more besides; solely or exclusively.
   "there are only a limited number of tickets available"
   synonyms:at most, at best, (only) just, no/not more than; More

   <https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+barely&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDEQ_SowAA><https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+scarcely&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDIQ_SowAA><https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+hardly&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDMQ_SowAA><https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+narrowly&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDQQ_SowAA>

   <https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+exclusively&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDUQ_SowAA><https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+solely&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDYQ_SowAA>
   -

      <https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+merely&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDcQ_SowAA><https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+simply&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDgQ_SowAA><https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+just&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDkQ_SowAA>
      -
      -
      2. *2*.
   with the negative or unfortunate result that.
   "she turned into the parking car, only to find her way blocked"
   -
      **

*adjective*
**

   1. *1*.
   alone of its or their kind; single or solitary.
   "the only medal we had ever won"
   synonyms:sole<https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+sole&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDsQ_SowAA>
   , single<https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+single&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CDwQ_SowAA>,
one
   (and only), solitary<https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+solitary&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CD0Q_SowAA>
   , lone<https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+lone&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CD4Q_SowAA>
   , unique<https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+unique&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CD8Q_SowAA>
   ; More

   <https://www.google.com/search?safe=off&espv=210&es_sm=119&q=define+exclusive&sa=X&ei=j21gUtKZCaWriAKK04HQCw&ved=0CEEQ_SowAA>
   -

*conjunction*
informal
**

   1. *1*.
   except that; but for the fact that.
   "he is still a young man, only he seems older because of his careworn
   expression"







If we want to avoid it, it's better to have completely separated interfaces.


Care to make a concrete proposal?



>
> --
> Simon Pieters
> Opera Software
>



-- 
    Cheers,
    --MarkM

Received on Thursday, 17 October 2013 23:12:51 UTC