Re: 3.0.3

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

Juergen Luethje wrote:
> 
> CChris wrote:
> 
> <snip>
> 
> > PS for Pete: anyway, I'd expect boolean() to crash if fed a sequence, so my
> > routine can indeed be used as a function. If you want a return of 0 for
> > sequences, then indeed it is not suitable.
> 
> So you can use it yourself as a function, because it works like you expect.
> However, I think about 99% of the Euphoria programmers expect a type when
> used as function _not_ to crash, but to return either TRUE or FALSE.
> 
> Regards,
>    Juergen

Are you sure? It depends on the context, in my view, as an atom may be a
boolean and a sequence never can. This is why the argument type for a type
is not "object" by default, which your comment would imply.

At any rate it is easy to conform to that no crash policy:
global constant FALSE = 1=0
               ,TRUE = not FALSE

global type boolean(object x)
integer y
y=not compare(x, TRUE) -- y is TRUE iff x is, otherwise it is FALSE
return not compare(x, y)
end type

I'm afraid it would slow things down a little. Any benchmarks?

CChris

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

Search



Quick Links

User menu

Not signed in.

Misc Menu