Multi dimensional array #522
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implement support for multidimensional array, and
:initial-contentsargument tomake-array.Array representation is somewhat standardized, some details are changed:
dimensionsproperty floating around, and this leads to bugs like vector dimensions are wrong #488. Even after patches here and there, there's still missing cases. For this PR I first tried to plug all the holes -- which almost works, except for a. this creates lots of friction when using JavaScript functions that treat only vectors as first-class citizen; b. I realize JavaScript arrays passed from FFI would still be missingdimensionsproperty anyways. So I settled on the solution in this PR: storedimensionsproperty only for 0-D and multi-dimensional array, andvectors don't havedimensionsproperty.typeproperty. CL standard and other implementations don't support arbitrary array element types, and these are always tied to the underlying array representation. For our casestringpalready has enough information. In the future we might want to support more element types by using JavaScript Typed Arrays.BTW, how much do we care about legacy browsers? JavaScript Typed Arrays are ECMAScript 6, are we ok with requiring it? Or using it but provide a fallback?
p.s. Now that
arefasethandle general multi-dimensional array, it's expected to have some performance penalty. I measured below 5% fortests.html. I think this is acceptable because I'd like to reach complete CL first. And the overhead can be easily removed once we have compiler macros.