3 ms·
First of all, Julia does have union types. But how does that help when the caller gives you a user-defined type?
by DNF2 4y ago
First of all, Julia does have union types. But how does that help when the caller gives you a user-defined type?
- recursivedoubts 4y agow/ proper union types, you just chuck another type, user defined or not, in the method signature and type cast via whatever syntax you have available in the implementation
- DNF2 4y agoSo you live in a world where there's a fixed number of built-in types hard-coded into your library? I'm afraid that doesn't cut it in a modern programming context.
- adgjlsfhk1 4y agothat only works if the method knows about all the types that might exist. The reason overloading is necessary is that the person that writes + for your programming language doesn't know all the types that people will want to call + on. As such, you need a way to define new implementations of + when people add new types in the future. This forces you to have some form of overloading.