We decided last week that we screwed up with the slice() naming, and changed the name of that function to subset(). We should get this change in, so that we can get a real slice() in the future. (Current slice() creates a new view object, but still references the same underlying data.) Marking this as a softblocker for API consistency, but I'll post a patch tomorrow.
Why "subset"? There's no sane set-theoretic interpretation. As P. Tucker Withington pointed out, the view objects are like Common Lisp's "Displaced Arrays". Not that you should use that name. "sliceView"? /be
Created attachment 508511 [details] [diff] [review] rename slice -> subset renamed, and tests updated; also added a test to ensure that subset() behaves as intended (references same buffer).
CC'ing some others who might get broken by this. FYI, gentlemen.
I don't have a good answer as to "why subset", other than that Ken & I liked that name, and it didn't collide with "slice"; the slice wart we should've caught a while ago (and I think Brendan even mentioned it originally :/)
Wow, "subset" smells pretty funky to me... neither the original array nor the result array is a set. I can see how "slice" could be misleading given that array.slice produces a fresh array. How about "subarray"? Some of the original work on this kind of API was known as "subsequences" since it was about taking pieces of (possibly mutable) sequence types that share references: http://portal.acm.org/citation.cfm?id=133234 Seems like a good analogy: subarray : array :: subsequence : sequence. Especially since an array is a kind of sequence. Dave
subrange, subview, sharedRange, sharedSlice
I don't think we get to pick a new name at this point... Ken already made the change in WebKit. Cc'ing him here -- really should get some JS folks involved in the typed array work :)
Fair enough, throwing them out just in case. As far as JS people getting involved, my understanding is that ECMA is doing its own thing in this space, looking to supplant typed arrays. See comment 575688 comment 6.
Comment on attachment 508511 [details] [diff] [review] rename slice -> subset (Argh, I hate that you're not :waldo :-) Yeah, TC39 is doing its own thing, but we have this now and will likely have it for quite a while... we're already depending on it very heavily for a lot of Fx4 launch demos and the like :-)
Comment on attachment 508511 [details] [diff] [review] rename slice -> subset rs=me assuming it builds and tests out fine. We should eventually move this over to use the atom stuff and shared const char in jsatom.h, but that certainly doesn't need to happen now, nor should it, really.
Since we've already broken content with the slice -> subset renaming, I suppose if we quickly renamed it again it wouldn't be that bad. Of the above suggestions, I like subarray the best. There are more view types of ArrayBuffers than just the Typed Arrays, in particular DataView, which doesn't support this operation. Therefore subview doesn't seem appropriate. subrange seems okay, but if we're adding more letters to the method name it seems to me we might as well keep the name focused on the array-like nature of these objects. Vlad, what do you think?
"Since we've already broken content with the slice -> subset renaming, I suppose if we quickly renamed it again it wouldn't be that bad." Let's go 'derper' with the renaming now: http://images0.memegenerator.net/ImageMacro/3784263/we-need-to-go-derper.jpg?imageSize=Medium&generatorName=Inception
If you're ok with an additional rename, subarray sounds fine, or 'subarrayview', but now maybe we're trying too hard.
+1 on subarray. (subarrayview is overlong and violates camelCaps -- subarray does not if it's one word, which neologisms and back-formations quickly become, esp. in hacker jargon.) /be
If we're in agreement on subarray, I'll update the Typed Array spec and conformance tests and do yet another rename on the WebKit side. Vlad?
sounds good to me, i'll update this patch
Created attachment 508837 [details] [diff] [review] rename slice -> subarray slice -> subarray!
7 years ago
I hope I don't come back here to see that it's been changed another two times.
Comment on attachment 508837 [details] [diff] [review] rename slice -> subarray rs=me again
http://hg.mozilla.org/mozilla-central/rev/84c8b33619e0 death to slice, long live subarray.
argh, the commit comment is wrong; I meant subarray! (code is correct)
This turned tests orange. I checked in a attempted fix: http://hg.mozilla.org/mozilla-central/rev/808970eca6d5
(In reply to comment #23) > This turned tests orange. I checked in a attempted fix: > http://hg.mozilla.org/mozilla-central/rev/808970eca6d5 And the checkin comment/stale bug summary bites. Sicking renamed the calls from slice to subset! Vlad, can you fix? rs=me /be
Ugh, didn't realize that the checkin-comment didn't reflect reality. Backed out the whole thing since this has already kept the tree orange for several cycles and my fix was risky enough as I didn't have time to compile a fresh tree and test. http://hg.mozilla.org/mozilla-central/rev/298c555d0c6e
For what it's worth, my patch didn't apparently cover all cases which needed s/slice/subfoo/
Yeah, sorry -- I tested JS, but forgot that the webgl tests had coverage of this :( I have everything patched locally (with correct commit message this time), but refreshing my build to make sure everything's good.
relanded with additional webgl test fixes.
Reminder that this is one that should have gotten a dev-doc-needed keyword on it. :) That said, documentation has been updated, thanks to Dave Humphrey's blog post catching my eye.