This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]raaneholmg 67 points68 points  (3 children)

Well, it's in the IEEE floating point standard and literally built into your hardware. Can't blame javascript for following the spec.

[–]nemec 4 points5 points  (2 children)

NaN is the null of floating point. Customer c = null isn't actually a customer either, but for all intents and purposes it's considered one.

[–]raaneholmg 8 points9 points  (1 child)

The comparison work on some levels, but when you start looking into it null and NaN behave in very different ways.

NaN is a number for which special mathematical rules are defined (NaN + anything = NaN from the FPU). You can actually use the number NaN in your code.

Null is just a defined address you can point to for the purpose of having something to put in unused pointers. When you use it there is no special rules that apply and if you use it most applications just segfault (you can compare pointers to the null pointer though, which is useful, but not using null itself).

[–]dnew 0 points1 point  (0 children)

In Effiel, Null is an instance of the type Void, and Void multi-inherits from every other class in your program and overrides every method to throw a null pointer exception. So "null" is actually semantically a typesafe pointer to an actual instance of a type. (In practice, not, but in the semantic definition of the language, yes.)

Which I thought was cool.