manifold icon indicating copy to clipboard operation
manifold copied to clipboard

Implicit equals for ==

Open JorgeCepeda opened this issue 2 years ago • 3 comments

Like in some languages like Rust, make == compare by value using equals() if configured to do so, while maintaining some way of comparing pointer equality

JorgeCepeda avatar Mar 09 '23 11:03 JorgeCepeda

Maybe introduce the eq, ~==, ~= or #= or something similar for equals()? I think a lot of code would break if you replaced all == with equals()

Alternatively, <value> eq could create a predicate and <value> eq <otherValue> would test that predicate. So <value> eq would be compiled to otherVal -> <value>.equals(otherVal) and <value> eq <otherValue> would become (<value> eq).test(<otherValue>) which is otherVal -> <value>.equals(otherVal).test(<otherValue>)

CC007 avatar Sep 11 '23 10:09 CC007

Could you explain it differently? I got lost in the third paragraph. Maybe this == behaviour could be opt-in per file or something?

JorgeCepeda avatar Sep 15 '23 23:09 JorgeCepeda

I was just thinking of how it could be implemented in a way that java understands it, because at the end of the day, all these manifold features are just syntactical sugar that needs to be compiled down to java.

CC007 avatar Sep 16 '23 17:09 CC007