Conversation
|
|
Perhaps it would be best to expand and clarify the note at the top of the module instead; this is useful information and it's left implicit by that note right now. |
|
My mistake. I assumed Could an optimizer figure out that this is our intention, and avoid copying the array upon push? |
|
I highly doubt it; I can’t see that being safe unless it’s handled by the JS VM. |
|
Yeah, I'm not sure why it's implemented with slice rather than it being The only way we could safely avoid copying arrays is with linear types, so we know they're not reused, etc. |
Applied that change in the latest commit. Now what should the runtime notes be for the other functions? Should we either:
For the latter, which note format do you prefer? I see these three varieties in the docs:
|
|
I would prefer the third. I think we should explicitly say what |
|
I think most functions should have complexity noted, although not all. For instance, it doesn't really make sense to give |
Added some more running time notes. Wasn't sure about some of these though ( Also seems like |
It would be nice to be upfront about the runtime benefit of
snoc, rather than having users confirm this for themselves by looking inArrays.js.