1. Re: EUPHORIA Digest - 25 Oct 1998 to 26 Oct 1998 (#1998-162)
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Oct 27, 1998
- 331 views
- Last edited Oct 28, 1998
>I never played attention, but i did pay attention. When I try or-ing two >values together, and then not-ing them, i always get 1. Take a look at >this: >printf(1,"%d",{not 100 or 10}) >Run that, and you'll see 1. Try changing the values, the output will >still be 1. Matt, it really *does* work. Test it, try it. a xor b --> ( a and ( not b ) ) or ( not (a) and b ) But, actually I prefer Carl's suggestion: a xor b --> (a) != (b) Yet, both *will* work. And this (for me) shows we dont *need* an XOR operator, but as for readability and for the sake of completeness, I do agree with you and Jiri. It would just be cleaner. As for the other comment (by John Bown) about expression evalutators returing an atom TRUE/FALSE value instead of a sequence containing the individual comparisments, I do *not* agree for a number of reasons: 1) Then you would need recursive routines to perform the expression on every element of the sequence. 2) It would brake existing code 3) It is in contrast with everything else we do in Euphoria: {1,2,3} + 1 = *a sequence* 4) You cannot say things like {1} > 1, it makes no sense. 5) In my opinion 'sequence' is not a datatype, it is a container. A sequence itself is never a value, it are a number of values (atoms) that are structured together. 6) You could make this one function to help fix your problems, while backwards this is not possible. function true (object x) if sequence (x) then for index = 1 to length (x) do if not true (x) then return 0 end if end for else return x end if end function if true ("Euphoria" = "Euphoria") then -- Easy enough ? end if -- But how would you make a function that, in your scenario, would do the opposite, and give the expression result as Euphoria currently gives you ? You would need to re-built every expression evaluator as a function, while I achieved the same with only *one* clear obvious function. (maybe even one Euphoria *should* support natively, as a quick built-in function.) >>This is a nice example, of a place, where Euphoria can make it a lot >>simpler, just by being Euphoria.. >Yup, i knew it. Someone had to correct my programming grammar. Do i make >it as a Eu progger? "Correct" .. well, Matt there is no right or wrong. Its a preference of style. And if you want to see an example of, in my own eyes, bad style, you should take a look at some of *my* older programs . Made after I knew Euphoria far longer than you did. Maybe somewhere some one still has my first mazer library.. (that created mazes) or you can take a look at clone, a game I finished up at the end of this summer, when I happen to take a look at it again, the original code was about 1 or 2, maybe 3 years old, I think. Ralf