3 ms·
> Why is this desirable vs. implementing those types in the language itself? That's a very good question. 1. It's simpler. In D, we transitioned from a builti
by WalterBright 5y ago
> Why is this desirable vs. implementing those types in the language itself?
That's a very good question.
1. It's simpler. In D, we transitioned from a builtin complex type to a library type. It was a happy experience. The simpler the compiler, the easier it is to deal with.
2. Most any programmer can create a library type. Relatively few can modify a compiler to add a new type.
3. It takes the pressure off the compiler team to develop more arithmetic types.
4. Users can add arithmetic types without needing anybody's consent, and can do it right now.
5. It tests and verifies the metaprogramming abilities of the language.
- joshuamorton 5y agoElaborating on 3/4: the domain experts don't need to be compiler experts too. There are always going to be more numeric-like types (int, float, complex, bigint, rational, symbolic-comp types etc.). Numeric vectors that act like numbers are useful (see: numpy), and trying to stick those all into the language is far harder than allowing extensibility.