tardy v0.0.1 - Runtime polymorphism without inheritance
jmh530
john.michael.hall at gmail.com
Tue Jun 16 11:24:05 UTC 2020
On Tuesday, 16 June 2020 at 09:15:10 UTC, Atila Neves wrote:
> [snip]
>> In the more longer-term, is the goal of the project to
>> implement a Typescript / Go interfaces like structural type
>> system in user space?
>
> Yes. Other than allowing multiple interfaces, I think it's
> already implemented.
I'm not familiar with what Typescript does, but doesn't Go allow
interfaces to be implemented by free-standing functions? That is
a little bit more similar to open methods. This requires the type
inherit from the interface and implement member functions.
>
>> Also how would it compare to Rust traits?
>
> Rust's traits are usually used like D's template contraints and
> Haskell's type classes. The only way they're relevant here are
> trait objects:
>
> https://doc.rust-lang.org/reference/types/trait-object.html
>
[snip]
Similar to above, aren't Rusts's trait objects defined using
separate impl blocks, rather than as member functions.
---
I'm not that knowledgeable of Boost, but I see some similarities
with Boost's type_erasure library. However, one main difference
is that it is implemented with concepts, rather than the
equivalent of interfaces. I would guess using interfaces has some
benefits in terms of implementation since you know exactly what
functions need to be called. Something like @models is very
flexible, but that might be a downside.
More information about the Digitalmars-d-announce
mailing list