Re: How to correctly spec sequences requiring an iterable

> This is an API design issue and I'd argument that such an overload is bad design.

And yet here we are with IDBDatabase and IDBObjectStore which very 
purposefully introduced such an overload.

And we have jQuery.prototype.init which allows overloading a "selector" 
for which typeof returns string with various other stuff including 
arraylikes.

And if you look at jQuery's makeArray it has bits like:

   if ( isArraylike( Object(arr) ) ) {
     jQuery.merge( ret,
                   typeof arr === "string" ? [ arr ] : arr
     );
   }

(note that their isArraylike returns true for strings).

Or cases all over where jQuery overloads strings and objects:

   options = typeof options === "string" ?
     ( optionsCache[ options ] || createOptions( options ) ) :
     jQuery.extend( {}, options );

(consider what happens if "options" is a String object!).

And lots of other places all over jQuery that treat primitive strings 
differently from String objects.

Now either jQuery is full of bad API design here, or people actually 
want APIs like this in some cases...

-Boris

Received on Friday, 15 November 2013 19:03:23 UTC