Re: Array initialization
Stefano Corsi <[email protected]> Mon, 27 Jan 2003 17:11:43 +0000
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Organization | Moto Project |
| Message-ID | <[email protected]> |
Alle 15:58, lunedì 27 gennaio 2003, David Hakim ha scritto:
> If pippo is declared as 'int[][][] pippo' you should be able to do the
> following print fine without the cast.
It's true!!!!!!!! This works:
int[][][] pippo = <int[][][]>[
[1,2],
[2,4],
[
[8,9],
[10,11]
]
];
print pippo[2][1][1];
I didn't noticed it. Isn't it beautiful when things take their place
automagically?
And now... any hint on the compiled version? Assign values to array is
puzzling me. In the interpreted version I did:
MotoVal *val;
MotoVar *rvar;
...loop...
val = opstack_pop(env);
rvar = moto_createVar(
env,NULL,
r->refval.subtype->name,
r->refval.dim - dimarr[0],
'\1',
NULL
);
rvar->address = &ua->aa.data[i];
moto_setVarVal(env, rvar, val);
moto_freeVal(env, val);
moto_freeVar(env, rvar);
...end loop...
Stefano