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

Re: APIs that have boolean arguments defaulting to true

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 11 Nov 2013 15:44:53 -0500
Message-ID: <528141C5.3000808@mit.edu>
To: Domenic Denicola <domenic@domenicdenicola.com>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
On 11/11/13 3:18 PM, Domenic Denicola wrote:
> For example, `node.clone({ shallow: true })` or `node.clone({ deep: true })` seems much better than `node.clone(true)` or `node.clone(false)`.

Those have the same exact issue.  If you define something like:

   interface Node {
     Node cloneNode(optional CloneOptions arg);
   };

   dictionary CloneOptions {
     boolean deep = true;
   };

then you get { deep: foo } producing a deep clone but { deep: !!foo } 
producing a shallow clone if foo is undefined.

So we would in fact want this to be:

   dictionary CloneOptions {
     boolean shallow = false;
   };

if we want to default to deep clones.

-Boris
Received on Monday, 11 November 2013 20:45:23 UTC

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