1. Error in Euphoria compiler?

I noticed a discrepancy between how the interpreter and compiler treat 
sequences in tests. For example:

if "this is a sequence" then
   puts( 1, "it's true" )
else
   puts( 1, "it's false" )
end if


Running under the interpreter, it throws a bad type error. The compiler 
figures out that it's not an integer or atom, but instead of throwing a type 
error, it just evaluates it as false.

-- David Cuny

new topic     » topic index » view message » categorize

2. Re: Error in Euphoria compiler?

David wrote:
> I noticed a discrepancy between how the interpreter and compiler treat 
> sequences in tests. For example:
> 
> <font color="#330033"></font>
> <font color="#0000FF">if </font><font color="#00A033">"this is a sequence"
> </font><font color="#0000FF">then</font>
> <font color="#FF00FF">   puts</font><font color="#330033">( 1, </font><font
> color="#00A033">"it's true" </font><font color="#330033">)</font>
> <font color="#0000FF">else</font>
> <font color="#FF00FF">   puts</font><font color="#330033">( 1, </font><font
> color="#00A033">"it's false" </font><font color="#330033">)</font>
> <font color="#0000FF">end if</font>
> <font color="#330033"></font>
> 
> Running under the interpreter, it throws a bad type error. The compiler 
> figures out that it's not an integer or atom, but instead of throwing a type 
> error, it just evaluates it as false.

The compiler's (i.e. translator's) mandate is to make your
program run fast. It catches all compile-time errors but is not 
required to catch run-time errors (subscripts out of bounds,
incorrect type of data etc.).
It does catch a few run-time errors, mostly in run-time routines 
shared with the interpreter, but by and large it assumes that you 
have debugged your program already using the interpreter.

Using a sequence in an if-condition is handled as a run-time
error, although in your example it's pretty obvious at 
compile-time. I could add a bunch of semi-redundant ad-hoc 
tests for specific errors like this in the shared front-end, 
but I'm not keen to do so, unless there's something that 
comes up with great frequency.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: Error in Euphoria compiler?

Robert Craig wrote:

> The compiler's (i.e. translator's) mandate is to make your
> program run fast. It catches all compile-time errors but is not
> required to catch run-time errors (subscripts out of bounds,
> incorrect type of data etc.).

OK. I noticed similar type check errors, such as:

   integer a
   printf( 1, "%d", a )

reports a "not enough args" error instead of "undefined variable", but it's 
the same sort of thing so it makes sense.

Besides, printf is sort of the exception to the rule of Euphoria routines. 
Even the intereter version accepts all sorts of wacky values.

> I could add a bunch of semi-redundant ad-hoc
> tests for specific errors like this in the shared front-end,
> but I'm not keen to do so, unless there's something that
> comes up with great frequency.

I agree, most of this stuff should be caught by the interpreter.

Thanks!

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

4. Re: Error in Euphoria compiler?

>Besides, printf is sort of the exception to the rule of Euphoria routines.=

>Even the intereter version accepts all sorts of wacky values.

Not to mention the fact that you can write stuff like:

=B4 (1,"%d",3)

..which will be treated as a printf. Maybe it's a leftover from an older=
=20
version.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Error in Euphoria compiler?

On Mon, 07 Jun 2004 10:10:23 +0200, mic _ <stabmaster_ at hotmail.com>
wrote:

>>Even the intereter version accepts all sorts of wacky values.
>
>Not to mention the fact that you can write stuff like:
>
>=B4 (1,"%d",3)
>
>..which will be treated as a printf. Maybe it's a leftover from an older
>version.

I think it is part of the shrouded source handling, which naturally
uses some obscure byte values instead of full keywords.

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu