3 ms·
> If it helps, think of it this way: a concept function is a 1-method trait on an implicit parameter. No, that just underscores the problem, it's just duck typ
by tialaramex 5y ago
> If it helps, think of it this way: a concept function is a 1-method trait on an implicit parameter.
No, that just underscores the problem, it's just duck typing. This "1-method trait on an implicit parameter" doesn't deliver semantics.
Let's look at an actual Rust trait, Eq. https://doc.rust-lang.org/std/cmp/trait.Eq.html https://doc.rust-lang.org/std/cmp/trait.Eq.html and notice that the implementation of this trait is empty. For a duck typing system there is nothing to check, syntactically Eq doesn't do anything.
But of course semantically Eq is rich with meaning. You can't go around using a HashMap with keys that don't exhibit Equivalence, what's that going to do? Nothing good.
- verdagon 5y agoI see now what you mean, youre talking about structural interfaces, like Go and Typescript have. Yes, concept functions are those applied to generics. You may not like structural interfaces, but they're much better at decoupling data from how it's used. People who have used both Typescript and Rust often wish more languages worked with structural interfaces like Typescript does. It's easy to see why, looking at the examples in the article. I believe in decoupling, and think a good language will have as little coupling as possible. To each their own though!