On Wed, 18 Sep 2002, Aldo Calpini wrote:
>
> I couldn't find any example of using a MultiArray PMC.
> I tried on my own, but failed miserably.
>
> from what I've seen, it seems that is impossible to
> properly initialize a multidimensional MultiArray.
>
> I've tried this:
>
> new P1, .MultiArray, 1000
>
> set P1[0;0], 1
> set P1[0;1], 2
> set P1[0;2], 3
>
> print "(0,0)="
> set I0, P1[0;0]
> print I0
>
> # prints:
> # (0,0)=3
>
> end
>
> every assignment changes whe whole P1[0] array.
> it seems to lose the 2nd dimension somehow, probably because
> the "dimension" member of the PMC was never initialized.
>
> how do I go on using this? what do we need to make it work?
Im sorry i havent responded in a resonable amount of time, im very very
busy at the moment with other things then parrot..
Multiarrays has one big problem that i havent fixed.
It lacks initialization code. Why does it do that one might ask.
I was moving for a syntax like this:
new P1, .Multiarray[1;2;3]
for simplicity but on the way it got rejected or my
patches that makes this possible is still not applied.
If i've understood Dan correctly initializing a multiarray should follow
this syntax:
new P0, .Key
set P0[1000;2000;300]
new P1, .Multiarray, P0
or similar.
I would really apreciate if someone would like to work on multiarrays.
Here's a todo list:
* add init_marray call in set_integer, set_pmc etc... should fix
initialization
* make get_marray_keyed return other types then only integers, something
like the old KEY_ATOM. cell_ structure has an UnionVal entry but is
missing an entry on what type UnionVal is, should look something
like HASH_ENTRY in hash.h.
Does anyone feel like it's something they would like todo. It's not rocket
science, though very good project for someone who havent written pmc's
before and would like to learn.
I almost forgot current implementation
dosent support dynamic growth.. feel free to solve that problem :-)
/Josef
>
>
> cheers,
> Aldo
>
> __END__
> $_=q,just perl,,s, , another ,,s,$, hacker,,print;
>
>