Re:Brad Cox: when OOP was about “Software-ICs” and micro-tra...
by steveklabnik on Friday December 20, 2019 @10:19PM
(#21849376)
It won’t be dynamically dispatched in Rust unless it’s a trait object.
[ Parent
| on HN ]
Re:Brad Cox: when OOP was about “Software-ICs” and micro-tra...
by xscott on Saturday December 21, 2019 @02:35AM
(#21850182)
I think your point is to emphasize there is no additional cost to method syntax. I wasn't trying to imply there was, only that when you want dynamic dispatch, you can only get it from method syntax.
Another interesting asymmetry, which I think shows a weird favoritism for method syntax is that Rust allows both of these:
object_of_type_A.foo()
object_of_type_B.foo()
But not both of these: foo(object_of_type_A)
foo(object_of_type_B)
Ignoring dynamic/static dispatch for the moment, you can overload if you use method syntax, but not if you use function syntax. For me, I would prefer the latter, but I think I'm clearly in the minority.