Re: Phix : variable types
- Posted by petelomax Dec 08, 2016
- 1297 views
Like this:
global function w32remainder(object a,object b) if sequence(a) then for i=1 to length(a) do a[i]=remainder(a[i],b) end for return a elsif sequence(b) then -- for i=1 to length(a) do for i=1 to length(b) do b[i]=remainder(a,b[i]) end for return b end if if compare(a,0.0)=compare(b,0.0) then return remainder(a,b) else return b+remainder(a,b) end if end function
Phix has, quite correctly, found a bug which has lain undetected in w32remainder for donkey's years - I first found that particular case in July 2009.
Were you to invoke w32remainder(1,{2,3}) on OpenEuphoria it would either:
a) crash on any older version where length(atom) crashed, or
b) only ever process b[1], and that way go quietly wrong.
Also, invoking w32remainder(1,{}) would crash every time, if that actually counts as a bug.
In Phix, length(atom) is [still] an error, for reasons just like this.
Pete
PS: If you are using a version of win32lib other than the one (0.60) shipped with Phix, it will be worth checking any errors against demo\win32lib6 to see if it has already been found and fixed, although that does not apply to the one above.
PPS: I have also long suspected that both the a[i]/b[i]= statements should really be recursive calls to w32remainder... maybe.