Re: APIs that have boolean arguments defaulting to true

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