4 ms·
How can you call a method on a type if you don't know anything about it ? How do you even know the method exist without some dynamic casting of sorts ?
by bestouff 3y ago
How can you call a method on a type if you don't know anything about it ? How do you even know the method exist without some dynamic casting of sorts ?
- noelwelsh 3y agoIt's not calling methods on a type that is the issue. It's passing parameters to a method or function when that method or function has a generic type for that parameter. In Rust this is something like fn foo<A>(a: A): A (which can only have one implementation, the identity, if you don't break the abstraction barrier provided by generic types.)
- dangitdangitdan 3y ago[flagged]
- Joker_vD 3y agoYou pass that method along with the value, so it's the caller's responsibility. At some point along the call stack there will be a monomorphic function which has to know the actual type it's calling its polymorphic callee with.