3 ms·
That's not quite correct. Concept functions can easily be checked ahead of time, theyre basically generics under the hood. C++ uses duck typing, but Vale doesn
by verdagon 4y ago
That's not quite correct. Concept functions can easily be checked ahead of time, theyre basically generics under the hood.
C++ uses duck typing, but Vale doesn't have to.
If it helps, think of it this way: a concept function is a 1-method trait on an implicit parameter.
- tialaramex 4y 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 4y 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!