simap / pixelblaze

Files related to Pixelblaze
https://www.bhencke.com/pixelblaze
229 stars 29 forks source link

Questions about arrays #8

Closed pavellishin closed 5 years ago

pavellishin commented 5 years ago

Howdy! I'm trying to write some patterns for a buddy's cube, and I've written something to help me test locally, but I'm still unsure of language limitations.

I see that array literals aren't permitted, but does array.length exist? Can arrays be of variable size at all? When you create a new array with array(10), what are the initial values of that array?

simap commented 5 years ago

The language is es6 in syntax, but a limited subset of functionality is supported. Currently there is no object support, which rules out things like array.length and constructors. Thats why the way to allocate an array is different. I suppose I should have made a function like arrayLength(array).

Arrays, once created, are of fixed length. They work more like primitive arrays in other languages, though they can store elements of any value including functions or other arrays. Accessing an element outside of the bounds of an array will abort the current function and show an error in the editor and highlight the line responsible, but rendering will continue (the show must go on!).

Arrays are initialized with zeros.

BTW, this would be a good thing to ask in the forum!