Re: Conditional handling (was Re: Reading a file into a "sequence")
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Nov 19, 2004
- 466 views
On Thu, 18 Nov 2004 13:44:07 -0800, Jason Gade <guest at RapidEuphoria.com> wrote: >Pete Lomax wrote: <snip> >> It would be much faster just to create the boolean in the first place. >> (Which of course I firmly believe it should do) <snip> >> What the language should not do is create a sequence in situations >> where the only possible outcome of so doing is a crash. <snip> >Good point. So do you think that comparison operators should work >like equal and compare in if and when statements, or should it remain >as-is? OK, I'll be even more specific. This has been proposed many, many times before and I have never opposed it, just the "create a sequence of 1s and 0s and then immediately munge it to a true/false" part. Something like if name="pete" then is written at least once by every person who ever codes more than a dozen lines of Euphoria. It will /always/ crash. This cannot possibly be considered anything but wrong (especially when left to a run-time rather than a parse-time error - but see "cost" below) If the interpreter must get an atom (if, while, for, subscript, and slice, but not assignment, parameters, or constant expressions) otherwise it will crash, then it should use equal()/compare() as it obviously needs to for all relational operators. (IMHO, that is) I'll go further and accept that a perfect solution is not necessary. Should the compiler be in any doubt, then crash, forcing the programmer to resort to explicit equal() and compare() calls. Of course, part of the problem is that the parser does not understand when it needs an atom, eg: integer i i="fred" generates a run-time, not a parse-time error. (You can prove this more clearly by wrapping it in a procedure, and calling/not calling it) I'm perfectly aware why Rob does not want to implement this, because it will slow things down (quite a bit, in all probability). Even with that cost, yes, I still want it. Regards, Pete PS I also like the idea of "when" statements )