[webkit-dev] Optional parameter in IDL and undefined JS value
ggaren at apple.com
Fri Apr 22 15:00:37 PDT 2011
> I would suggest updating the specification for Blob.slice() so that it
> doesn't expect passing "undefined" for the second argument to have
> identical behavior to not passing the argument at all. The "subarray"
> method in the Typed Array spec , which has similar behavior to
> slice(), doesn't mention the undefined value.
> I am afraid that this suggested change might not be preferred since we're trying to mimic the behavior of Blob.slice to Array.slice and Array.slice does allow passing undefined and treat it as omitting the value.
Can you clarify why we want Blob.slice to mimic Array.prototype.slice in this strange argument quirk?
Let me suggest three reasons why we don't want Blob.slice to mimic Array.prototype.slice in this strange argument quirk:
2. A Blob is not an Array. Blobs are incompatible with all other Array semantics. They don't have a length property. They don't support bracket access. They don't support destructive modification. If Blobs were like Arrays, you could just use Array.prototype.slice to slice a Blob. But you can't, because they're not alike at all.
3. Your specification doesn't actually conform to the exact semantics of all the argument quirks of Array.prototype.slice. There are a number of other quirks that you have left out because they are strange and you are not familiar with them. I will leave it as a thought experiment for you to go and find all the other quirks of Array.prototype.slice that you have missed. While you are seeking them out, you can meditate on whether you are making your API better or worse.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev