Re: A bug in the interpreter
- Posted by Jason Gade <jaygade at yahoo.com> Feb 28, 2006
- 446 views
Alex Chamberlain wrote: > > Mathematically, 4 < n < 8 should evaluate to 4 < n and n < 8. Euphoria > should develop to reflect this as it is "correct". > > (4 < n) < 8 is different - as I see it. > > If n = 32, > (4 < n) < 8 = TRUE < 8 = 1 < 8 = TRUE which is incorrect! > > Alex I understand the mathematics behind it, but it is just notation. I can't think of any other common programming language that uses notation like this. Most languages that I'm aware of require the keyword 'and' to disambiguate the expression. For the second example, the programmer needs to be aware that comparing TRUE and 8 has no mathematical meaning. Since Euphoria doesn't have built-in boolean types the language just uses 1 and 0 as TRUE and FALSE. Some other languages use -1 and 0. Euphoria will also interpret any nonzero value as TRUE in the proper context. Again, this is pretty standard behavior in programming languages. Or at least the ones I'm familiar with (C and relatives, BASIC, Euphoria). -- "Any programming problem can be solved by adding a level of indirection." --anonymous "Any performance problem can be solved by removing a level of indirection." --M. Haertel "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.