Re: RFC: Breaking existing Euphoria functionality
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 22, 2007
- 579 views
Michael J. Sabal wrote: > > Has anybody written a statement like this: > > result = ({'a','b','c'} = {'a','b','f'}) > > and expected result to look like this: > > ? result > {1,1,0}? > > Is there any code in the archives or recent user contributions (say less than > 3 years old) that takes advantage of this functionality? > > I would like to change binary_ops() in be_runtime.c so that the result of > comparing two sequences with an operator (=,<,>,<=,>=,!=) returns a single > boolean rather than a sequence of booleans. The benefit to this change > would allow sequences to be compared in an if or while statement without > requiring compare or equal. The drawback is breaking existing functionality. > I expect the performance hit to be negligible. > > Michael J. Sabal Did you ever write
result= {1,2,3}+{4,5,6}
while expecting result holding anything else than {5,7,9}? If you answer "no" to this question, then consider that, on my keyboard at least, '+' and '=' are on the same key. Can anyone expect different behaviour from two operators located on the same keyboard key? It is possible that your proposed change wouldn't break much submitted code. But it would certainly add confusion to the syntax of the language. equal() and compare() perform what you appear to wish to do. What could be desirable, in code that heavily uses string comparisons, could be a new top level "without compare" statement that woul cause relational operators to operate on strings as atomic objects instead of collections of objects. If there was an "extend to sequence" operator in Eu, then the change you propose could be more palatable; {1,1,0} could be obtained by
result=(`{'a','b','c'}=`{'a','b','f'})
denoting by a backquote the extension operator. The [] suffix could be pretty clear too. CChris