On 7/23/2015 8:03 AM, Dicebot wrote:
At the same time one HUGE deal breaker with rust traits that rarely gets
mentioned is the fact that they are both constraints and interfaces at the same
time:
// this is template constraint, it will generate new `foo` symbol for each new T
fn foo <T : InputRange> (range : T)
// this use the very same trait definition but creates "fat pointer" on demand
with simplistic dispatch table
fn foo (range : InputRange)
It kills all the necessity for hacks like RangeObject and is quite a salvation
once you get to defining dynamic shared libraries with stable ABI.
This is probably my most loved feature of Rust.
D interface types also produce the simplistic dispatch table, and if you make
them extern(C++) they don't need a RangeObject. I know it isn't as convenient as
what you describe above, but it can be pressed into service.