Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 0.7
-
Component/s: Type System
-
Labels:None
-
Number of attachments :
Description
boo needs support for multidimension arrays of type Object[,], Object[,,], etc.
For creation, it was suggested to expand the array() macro to take a variable number of args, e.g.:
multi = array(Person,2, 3, 4)
would yeild a Person[,,] with lengths of 2, 3, and 4 for each dimension, respectively.
Access to the items can be done through an extension of the slicing syntax. Taking the above "multi" object, we can access a single entry by referencing mutli[0,2,3] or we can slice a range in each dimension by referencing multi[0:1,1:2,0-2] to get a new multi[,,].
I started work on this, and I think i've got the antlr part of things done, but the rest I'm not even close on.
Here's a diff to boo.g to add support to the parser to recognize mutli-dimensional arrays. Possible thank's to bamboo's redefinition in of the AST to better accomodate this.
Now when you compile:
b = Test2.ReturnIntArray()
print (b[1:1,0:1])
(Where Test2.ReturnIntArray() is some method written in C# to return a Object[,]) you get a nice message:
/home/peter/Array.boo(5,9): BCE0031: Language feature still not implemented: multi dimensional slicing.
Will work on the actually handling of MD arrays soon.
Is the macro array(Type, dimension_1_size, dimension_2_size, etc) agreed upon as a good syntax for MD arrays?