olch@geocub.greco-prog.fr (Olivier Charrier) (03/12/90)
I found a little problem when trying to use arrays of unknown sizes as arguments in Draco's functions. I typed the example given in the doc, which looks like that: proc minimum([*] int t) int: int min,i; min := t[0]; for i from 1 to dim(t,1) do if t[i] < min then min := t[i] fi od; min corp; The compiler returns the error 'cannot use sizeof on array with '*'' (or something like that), and indicates if t[i] < min then min := t[i] fi ^ If I replace i with a constant or a numeric, it works. Why does this happen? Cedric.
cg@ami-cg.UUCP (Chris Gray) (03/15/90)
In <1693@geocub.greco-prog.fr> olch@geocub.greco-prog.fr (Olivier Charrier) posting for gnu@cerisi.cerisi.fr (Cedric BEUST) writes: > I found a little problem when trying to use arrays of unknown sizes as >arguments in Draco's functions. I typed the example given in the doc, >which looks like that: > >proc minimum([*] int t) int: >int min,i; > > min := t[0]; > for i from 1 to dim(t,1) do > if t[i] < min then min := t[i] fi > od; > min >corp; > > The compiler returns the error 'cannot use sizeof on array with '*'' (or >something like that), and indicates > > if t[i] < min then min := t[i] fi > ^ > If I replace i with a constant or a numeric, it works. Why does this >happen? I tried the source from this article, and got a complaint about syntax (it should be 'upto' in the 'for', not 'to'), but after fixing that, it compiled fine. Can you mail me the exact routine that is failing? I used my V1.3 beta version of the compiler, but my log files going back to Jan 88 show no changes that could have fixed a bug like that. Also, since Draco arrays are 0 origin (same as C's), the 'for' loop should be: for i from 0 upto dim(t, 1) - 1 do ... od; If all else fails, I can uuencode and mail you V1.3. (I haven't released it yet since I want to do a whole new set of documentation.) -- -- Chris Gray usenet: {uunet,alberta}!myrias!ami-cg!cg CIS: 74007,1165