Julia: Literal NaNs in ASTs

Created on 31 Mar 2016  ·  3Comments  ·  Source: JuliaLang/julia

Perhaps comparing ASTs isn't a very common operation, but I came across the following which I found surprising. I think it is even arguable that == should ignore the facts that NaNs are not numerically equal to themselves since it's not really numerical comparison.

julia> :(f($NaN)) == :(f($NaN))
false

julia> isequal(:(f($NaN)), :(f($NaN)))
false

Most helpful comment

it is even arguable that == should ignore the facts that NaNs are not numerically equal to themselves since it's not really numerical comparison.

NaN literal is not NaN value, yep

All 3 comments

It looks like we need an isequal method for Expr that calls isequal recursively.

it is even arguable that == should ignore the facts that NaNs are not numerically equal to themselves since it's not really numerical comparison.

NaN literal is not NaN value, yep

Very good point. The real solution is probably for == on Exprs to use isequal to compare elements.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ararslan picture ararslan  ·  3Comments

iamed2 picture iamed2  ·  3Comments

dpsanders picture dpsanders  ·  3Comments

thofma picture thofma  ·  3Comments

StefanKarpinski picture StefanKarpinski  ·  3Comments