W3C home > Mailing lists > Public > public-html@w3.org > January 2010

Re: spec verbosity and algorithms

From: Julian Reschke <julian.reschke@gmx.de>
Date: Sat, 23 Jan 2010 08:47:32 +0100
Message-ID: <4B5AA994.8050009@gmx.de>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Karl Dubost <karl@la-grange.net>, "public-html@w3.org" <public-html@w3.org>
Tab Atkins Jr. wrote:
> On Fri, Jan 22, 2010 at 10:28 PM, Karl Dubost <karl@la-grange.net> wrote:
>> [23:24]  <TabAtkins> karlcow: Yeah, it's wrong.  The opaque-identifier portion should completely separate from the same-components section.  If they're opaque, they don't *have* components.
>> [23:25]  <karlcow> TabAtkins: ah. I'll modify. It is not clear in the prose of the spec I have the feeling.
>> [23:25]  * karlcow likes to visualize to understand
>> [23:26]  <TabAtkins> If you translate it from prose directly to if/then code in your favorite programming language, it becomes very clear.  ^_^
> function sameOriginP(A,B) {
>   if(opaque(A) && opaque(B) && A.value == B.value) {
>     return true;}
>   if(opaque(A) || opaque(B)) {
>     return false;}
>   if(A.scheme != B.scheme || A.host != B.host || A.port != B.port) {
>     return false;}
>   for(key in A.extraData) {
>     if(A.extraData[key] != B.extraData[key]) {
>       return false;}}
>   for(key in B.extraData) {
>     //have to do it both ways with this method, in case B has some
> extra data that A doesn't.
>     //there are probably better ways to handle this
>     if(A.extraData[key] != B.extraData[key]) {
>       return false;}}
>   return true;
> }

Once you use this notation you can simply say:

if (A.value = B.value and A.scheme = B.scheme and A.host = B.host and 
A.port = B.port and A.extraData = B.extraData)

Just define how missing components compare.

Offlist I was asked why verbosity is a problem. The answer is really simple.

As a reader, I want to know when two origins are equal. If this is 
defined in an 8-step algorithm, I'll have to work my way through this 
algorithm step by step and understand it.

In particular, given the sheer amount of instructions, I *will* be 
confused because it really doesn't contain any surprises.

This is a disservice to the reader.

BTW: I haven't been looking for this example, I just came across it 
while looking at iframe/sandbox questions.

Best regards, Julian
Received on Saturday, 23 January 2010 07:48:15 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:57 UTC