Re: type checking ?

new topic     » goto parent     » topic index » view thread      » older message » newer message

I wrote:
> }}}
<eucode>
> global function getstr(integer idx) -- or make defset global
>   if idx<1 or idx> length(defset) then ?9/0 end if
>   return defset[idx]
> end function
> procedure useit(integer idx)
> </eucode>
{{{


My OCD says: better typewise/error reporting is of course:
global type valididx(object idx)
   return integer(idx) and idx>= and idx<= length(defset)
end type
global function getstr(integer idx)
  return defset[idx]
end function
procedure useit(valididx idx)

 

Thataway any error should occur on the useit call itself, not two levels down in
the call stack...

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu