Closed Bug 630117 Opened 14 years ago Closed 14 years ago

rename typed array slice() to subarray()

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: vlad, Assigned: vlad)

Details

(Keywords: dev-doc-complete, Whiteboard: [softblocker])

Attachments

(2 files, 1 obsolete file)

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
Attached patch rename slice -> subset (obsolete) — Splinter Review
renamed, and tests updated; also added a test to ensure that subset() behaves as intended (references same buffer).
Assignee: general → vladimir
Attachment #508511 - Flags: review?
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 :-)
Attachment #508511 - Flags: review? → review?(jwalden+bmo)
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.
Attachment #508511 - Flags: review?(jwalden+bmo) → review+
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
ಠ_ಠ
slice -> subarray!
Attachment #508511 - Attachment is obsolete: true
Attachment #508837 - Flags: review?
Attachment #508837 - Flags: review? → review?(jwalden+bmo)
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
Attachment #508837 - Flags: review?(jwalden+bmo) → review+
argh, the commit comment is wrong; I meant subarray! (code is correct)
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Summary: rename typed array slice() to subset() → rename typed array slice() to subarray()
(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
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
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.
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
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.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: