Skip to content

Commit 4e57584

Browse files
committed
Discourage is T.nan, recommend isNaN
1 parent df678ee commit 4e57584

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

spec/expression.dd

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -616,26 +616,20 @@ $(GNAME IdentityExpression):
616616
bits in the operands being identical.
617617
)
618618

619-
$(SPEC_RUNNABLE_EXAMPLE_RUN
620-
---
621-
Object o;
622-
assert(o is null);
623-
624-
float f;
625-
assert(f is float.nan);
626-
---
627-
)
628-
629619
$(P For static and dynamic arrays, identity of two arrays is given when
630620
both arrays refer to the same memory location and contain the same number
631621
of elements.
632622
)
633623

634624
$(SPEC_RUNNABLE_EXAMPLE_RUN
635625
---
626+
Object o;
627+
assert(o is null);
628+
636629
auto a = [1, 2];
637630
assert(a is a[0..$]);
638631
assert(a !is a[0..1]);
632+
639633
auto b = [1, 2];
640634
assert(a !is b);
641635
---
@@ -712,7 +706,10 @@ $(H3 $(LEGACY_LNAME2 floating_point_comparisons, floating-point-comparisons, Flo
712706
$(TROW $(D ==),equal, `false`)
713707
$(TROW $(D !=),$(ARGS unordered, less, or greater), `true`)
714708
)
715-
$(P To check for `NaN`, use $(GLINK IdentityExpression).)
709+
710+
$(BEST_PRACTICE Although *IdentityExpression* can be used to check for `T.nan`,
711+
there are other floating-point values for NaN produced at runtime.
712+
Use $(REF isNaN, std,math,traits) to handle all of them.)
716713

717714
$(H3 $(LEGACY_LNAME2 class_comparisons, class-comparisons, Class Comparisons))
718715

0 commit comments

Comments
 (0)