Re: Why not == ?
- Posted by ghaberek (admin) Nov 07, 2022
- 579 views
A long time ago I had made a custom Euphoria interpreter that converted a = b to equal(a, b) when the operator was used inside an if or while statement. IIRC it may have had some bugs and I'm pretty sure I've since lost the code.
This is something I'd like to see implemented and I don't think it would break much existing code since boolean statements have to be atoms and all binary operations on sequences return a sequence or cause an error (if sequence lengths do not match).
I think the potential problems come from the reverse: statements like foo = a = b where a and b are equal-length sequences so foo would return a sequence as well. I think the solution here is two-fold:
- Only use = for boolean operations on sequences inside if and while statements.
- Issue a warning for statements like foo = a = b that equal() should be used instead.
- Possibly remove support for foo = a = b statements sometime later?
-Greg