Re: request for change of boolean

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

Derek Parnell wrote:

> Kat wrote:
> >
> >
> > Is it possible to change how boolean expressions are evaluated such that
> > only
> > values greater than 0 pass this test? :
> 
> Why? Is there a compelling reason to change the current implementation? For
> example, does it cause your programs to fail or run slower?
> 
> 
> > }}}
<eucode>
> > readfile = open(flagfilename,"r")
> > if readfile then
> > -- it's there, process it
> > end if
> > </eucode>
{{{

> 
> You should code this as ...
> 
>   if readfile < 0 then ...
> 
> Would that be a problem?
> 
> > Currently, if readfile = -1 , it evaluates to TRUE, when in fact
> > the readfile was not opened.
> 
> The valid values that can be returned from open() are all positive integers
> greater than 2. The values 0, 1, and 2 are pre-opened files for stdin, stdout,
> and stderr. Thus negative values are returned to indicate that the file could
> not be opened. A positive value would actually imply that it opened just fine.

True.
Eu's built-in open() function does not return boolean values. And
treating integers as boolean values can cause problems, of course.
But that's not Eu's fault.

<snip>

Regards,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu