Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Number isn’t an interface—there are no operations common to all numbers.

When creating a new type, it should be more clear cut when is subtyping Number (or Real, etc.) valid. Should unitful quantities be numbers? Should intervals be numbers? Related: I think there are some attempts by Tim Holy and others to create/document "thick numbers".

Furthermore, I believe it might be good to align the Number type hierarchy with math/abstract algebra as much as possible without breaking backwards compatibility, which might making Number, or some subtypes of it, actual interfaces.

> Subtyping Number is a way to opt into numeric promotion and a few other useful generic behaviors. That’s it.

OK, but I think that's not documented either.



Yeah, probably should be documented.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: