Re: RFC: Breaking existing Euphoria functionality

new topic     » goto parent     » topic index » view thread      » older message » newer message

I have a suggestion for this that will not break 
existing code at all.

Instead of changing the behavior of comparison operators,
why don't we just change the behavior of "if" ?

Normally only atoms are allowed for "if", 
like if 1 then.. if 0 then.. if a = b then (where a, b are atoms),
we change it to allow sequences.

Only if all the elements of the sequences are true,
the "then" part will be executed. Otherwise, the "else" part.

So we allow if {1, 1, 1} then ... as a result of if "abc"="abc"
and it will execute the "then" part.

OK I just realized it is not possible without changing one more thing
that is comparison of sequences of different length.
(we can't have "ab" = "abc")


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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu