archives

« Bugzilla Issues Index

#4369 — Would be nice to factor out byteOffset, byteLength, and buffer accessors into abstract ops


Then other specifications could call them, given an arbitrary object which the spec hopes is a typed array or DataView. And, I think it would dedupe the %TypedArray% versions and the DataView versions, unless I am missing a subtle difference between them.


(In reply to Domenic Denicola from comment #0)
> And, I think it would dedupe the %TypedArray% versions and the DataView
> versions, unless I am missing a subtle difference between them.

Do you mean this subtle difference?

DataView.prototype.byte{Length,Offset} throw a TypeError if the array buffer is detached, whereas %TypedArray%.prototype.byte{Length,Offset} return 0.


Wow, I am surprised that we are not having those throw but we are still having indexed access throw. The inconsistency is quite surprising as well.

But yes, I guess in that case we couldn't dedupe (without introducing a flag or similar). I'd rather in that case export an abstract op that has the behavior we want other specs to follow, which I assume is the throwing one.


(In reply to Domenic Denicola from comment #2)
> Wow, I am surprised that we are not having those throw but we are still
> having indexed access throw. The inconsistency is quite surprising as well.
>

Walking a fine line here regarding how much legacy implemented browser behavior can be changed without web breakage. Nobody knows...


Yeah, just not sure why we think byteLength and byteOffset throwing for DataView is any more or less compatible than it throwing for %TypedArray%.


(In reply to Domenic Denicola from comment #4)
> Yeah, just not sure why we think byteLength and byteOffset throwing for
> DataView is any more or less compatible than it throwing for %TypedArray%.

It's more a matter that each such potentially breaking change needs to be discussed with TC39.


I kind of doubt that when we discussed this for typed arrays everyone was implicitly adding "(but not DataView)" to their statements. More likely people just forgot to distinguish.


(In reply to Domenic Denicola from comment #6)
> I kind of doubt that when we discussed this for typed arrays everyone was
> implicitly adding "(but not DataView)" to their statements. More likely
> people just forgot to distinguish.

I certainly agree. DataView is included is just another typed array in these kind of discussions. Having them behave different here sounds like a bug.