Re: A bug in the interpreter
- Posted by Ricardo M. Forno <rmforno at tutopia.com> Mar 01, 2006
- 456 views
Ed Davis wrote: > > Daryl Border > > > It is not the responsibility of the interpreter to prevent > >the programmer from using poorly formed expressions such as (4 < > >n) < 8. > > Some people might say that "4 < n < 8" is a poorly formed > expression. If you are coming from the C/Java world, you would > say it is perfectly valid, but it does not mean "4 < n and n < > 8", but rather the (4 < n) < 8. > > >It is the responsibility of the interpreter to evaluate the > >expressions according to the rules of mathmatics. My code > >evaluates both expressions correctly. Euphoria currently does > >not. > > How does it correctly evaluate (4 < n) < 8? Does it treat (4 < > n) as a boolean, and then compare against that? > > What about "4 < n < 8 < a < b"? How should that be evaluated? Is > it "4 < n and n < 8 and 8 < a and a < b?" Should the interpreter > allow that? How do your changes evaluate it? > > Along the same lines, what about: "4 = n = 8"? It is also > currently accepted, and apparently interpreted as: > > (4 = n) = 8 > > The same way C would interpret it (well, replace the '=' with > '=='). > > Without understanding all the possible ramifications, I'm not > sure changing the current semantics is a good idea. One of the languages that has something similar is good old COBOL, because you may omit the variable name in the second comparison, but anyway it uses 'and'. Anyway, I think the main issue is this: are there fixed rules for the syntax and semantics of mathematical expressions? Newton, Leibnitz, Fermat, Euler, Gauss, etc,. all of them used different notations. What I was taught at school is now totally different. And I see the time coming when mathematical notation will evolve from computer programming languages. Regards.