Bug or not?

BlitzMax Forums/BlitzMax Programming/Bug or not?

JoshK(Posted 2011) [#1]
Is this a bug, or are resizable multidimensional arrays not supported?:
Type TFoo
EndType

Local a:TFoo[]
a=New TFoo[2]
Assert a

Local b:TFoo[,]
b=New TFoo[2,2]
Assert b'b equals Null



JoshK(Posted 2011) [#2]
Weird, I reinstalled 1.43b built all mods, and now it works fine.


Czar Flavius(Posted 2011) [#3]
Can you resize (using splicing) and keep original data?


col(Posted 2011) [#4]
You can re-size the array and add a spliced array to end in one line using for example

ArrayA :+ ArrayB[ 5..10 ]

But I don't think you can splice into the middle of an existing array without writing it yourself. I stand to be corrected as it would come in very handy.

One thing I did notice is that you can index beyond the arrays length with the spliced array. Say for example in the above, that ArrayB was at some stage defined as ArrayB[ 4 ], then the above will still work but append the extra elements with Null or Zeros.


Czar Flavius(Posted 2011) [#5]
Thank you. I meant, can you splice multidimensional arrays?


beanage(Posted 2011) [#6]
Thank you. I meant, can you splice multidimensional arrays?


Sounds impossible, considering the multidimensional arrays memory layout. Unless you use arrays of arrays, of course.


Jesse(Posted 2011) [#7]
it can actually be done. I have done it before.
Its as simple as creating a new array and moving the data which is actually what slicing does. the only downside is the more dimensions and the larger the size, the process becomes exponentially slow and the harder it is to create source to manage it.

Last edited 2011