Re: ? 1={}, is there really any other interpretation?
- Posted by Robert Craig <rds at R?pidEuphoria.c?m> Jul 17, 2007
- 686 views
Pete Lomax wrote: > Rob: Perhaps instead of asking "should we kill off sequence ops", which > I am not advocating, it is the IMPLICIT part that causes problems, the > questions that should be asked (as well) are: > Do we want short-circuiting in all expressions? In an ideal world, that might be nice. > This cannot be done > as long as "and" & "or" are sequence-op-capable, but could be if > "and" became atom-only and either "@and" or "sq_and()" created to > replace that particular functionality, ditto "or". I think it's a bit late in the game to change the semantics of "and", "or", "=", or any other operator when applied to sequences. > Do we want the 'if name="pete" then' gotcha to go away and instead > for such expressions to work as humans expect? Humans who were brought up on Basic are very disturbed by this. Humans who were brought up on C, think it's fine. In C you don't say: if (name == "pete") You say: if (strcmp(name, "pete") == 0) Since I was brought up on C (and APL, which works like Euphoria in this regard), I really can't see why people are so determined to replace: if equal(a, b) then by something like: if a == b then I don't see why that is so important. There wouldn't be any speed advantage, and we'd constantly have newbies asking what the difference is between == and =, and experienced users also frequently forgetting. > Do we want expressions to have the same meaning wherever they occur > or behave different in if/while to assign/params? In the context of an if/while/elsif we know that an expression can't produce a sequence as it's overall result, otherwise it would be an error, so we are "free" to sometimes ignore the remainder of the expression, and assume we are dealing with atoms only. Short-circuiting was retrofitted into Euphoria, and this little trick made it possible. I realize things aren't as clean in this area as they might be, but if you really want s.c. you can always change: x = logical_expression into: if logical-expression then x = 1 else x = 0 end if to get short circuiting. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com