4 ms·
I don't know GScript, but wouldn't it be enough to know which methods are declared in GScript (and not allow overloading for these)? Then type inference can wor
by skitter 4y ago
I don't know GScript, but wouldn't it be enough to know which methods are declared in GScript (and not allow overloading for these)? Then type inference can work fully most of the time and only give up when calling non-Java code.
Also, why does this complicate the parser? It looks like you're interfering some type information from later usage (the `foo( someVar )` example), so handling typing in the parser seems a bit strange.
As for the bytecode, it's not just methods: Fields likewise are identified by name and type and can be overloaded. I'm just happy that Java itself doesn't allow field overloading - I'm not the biggest fan of method overloading either.
- recursivedoubts 4y agothe parser gets more and more complicated as you score methods, this gets really, really, really nasty once generics get involved just an awful feature that solves no problems that can't be better done with other features that, for whatever reason, just aren't as popular
- adgjlsfhk1 4y agoHow else would you implement addition? What is another API that can handle adding objects of various types, (Int8,16,32,64, BigInt, Complex for all of these, rational for all of these, and Float16, 32, 64) that doesn't totally suck?
- recursivedoubts 4y agounion types
- DNF2 4y agoFirst 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.