You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recursively check for equality, avoiding pitfalls where eid(a) == eid(b) but func(a) != func(b) for elements (and similarly for custom types with tid(a) == tid(b))
With the exact parameter, we can also check for strict equality, which would allow us to properly implement dictionary and array literals (right now exact(...) on them doesn't work as expected).
Some ideas:
exact: false impl:
If a == b works, return true
If both are custom types with the same tid, then apply eq(a.field, b.field, exact: exact) for each field recursively
If both are custom elements with the same eid, then apply eq(a.field, b.field, exact: exact) for each field recursively
If both are dictionaries, apply eq(a.at(k), b.at(k), exact: exact) recursively (fail early if there is k in a which is not in b or vice-versa)
If both are arrays (fail early if they have different lengths), apply eq(a.at(i), b.at(i), exact: exact) recursively
Otherwise false
Possible optimization: Elements and types store whether all of their fields are "simple" to compare (fields(a) == fields(b) is enough), e.g. not structured (not content, dict or array)
exact: true impl:
If type(a) != type(b) return false early
If a == b and a, b are both "simple" types (not dictionary / array / content), then return true
Otherwise do the rest of the procedure above
The text was updated successfully, but these errors were encountered:
Recursively check for equality, avoiding pitfalls where
eid(a) == eid(b)
butfunc(a) != func(b)
for elements (and similarly for custom types withtid(a) == tid(b)
)With the exact parameter, we can also check for strict equality, which would allow us to properly implement dictionary and array literals (right now
exact(...)
on them doesn't work as expected).Some ideas:
exact: false
impl:a == b
works, return truetid
, then applyeq(a.field, b.field, exact: exact)
for each field recursivelyeid
, then applyeq(a.field, b.field, exact: exact)
for each field recursivelyeq(a.at(k), b.at(k), exact: exact)
recursively (fail early if there isk
in a which is not in b or vice-versa)eq(a.at(i), b.at(i), exact: exact)
recursivelyfields(a) == fields(b)
is enough), e.g. not structured (not content, dict or array)exact: true
impl:type(a) != type(b)
return false earlya == b
anda, b
are both "simple" types (not dictionary / array / content), then return trueThe text was updated successfully, but these errors were encountered: