Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining == for ComposedFunction by comparing inner and outer #53853

Open
sunxd3 opened this issue Mar 26, 2024 · 1 comment
Open

Defining == for ComposedFunction by comparing inner and outer #53853

sunxd3 opened this issue Mar 26, 2024 · 1 comment
Labels
domain:equality Issues relating to equality relations: ==, ===, isequal

Comments

@sunxd3
Copy link

sunxd3 commented Mar 26, 2024

== for ComposedFunction falls back to egal, c.f.

==(x, y) = x === y

Does it make sense to define something like

function Base.:(==)(cf1::ComposedFunction, cf2::ComposedFunction)
    cf1.inner == cf1.inner && cf2.outer== cf2.outer
end

related PR for Accessors.jl: JuliaObjects/Accessors.jl#146

@nsajko nsajko added the domain:equality Issues relating to equality relations: ==, ===, isequal label Mar 27, 2024
@nsajko
Copy link
Contributor

nsajko commented Mar 28, 2024

I suppose the proposal would be easier to evaluate with a PR that passes the test suite.

NB: if you define ==(::T, ::T), it's required to also define hash(::T, ::UInt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:equality Issues relating to equality relations: ==, ===, isequal
Projects
None yet
Development

No branches or pull requests

2 participants