Re: Error in Euphoria compiler?
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 06, 2004
- 353 views
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