Skip to content

Conversation

@kchanqvq
Copy link
Member

@kchanqvq kchanqvq commented Nov 27, 2025

This PR implement support for multidimensional array, and :initial-contents argument to make-array.

Array representation is somewhat standardized, some details are changed:

  1. We used to have arrays with no dimensions property 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 missing dimensions property anyways. So I settled on the solution in this PR: store dimensions property only for 0-D and multi-dimensional array, and vectors don't have dimensions property.
  2. I removed type property. CL standard and other implementations don't support arbitrary array element types, and these are always tied to the underlying array representation. For our case stringp already 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 aref aset handle general multi-dimensional array, it's expected to have some performance penalty. I measured below 5% for tests.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.

@davazp
Copy link
Member

davazp commented Dec 8, 2025

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?

I think TypedArray are fine. They would only be used in :element-type is specified right? so if we don't someone do not want to use them they can skip element-type.

@kchanqvq kchanqvq merged commit de93e51 into jscl-project:master Dec 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants