On Tuesday, 16 June 2020 at 11:24:05 UTC, jmh530 wrote:
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?

So does tardy.

That is a little bit more similar to open methods. This requires the type inherit from the interface and implement member functions.

There is no inheritance anywhere, otherwise that'd defeat the point of the library in the first place. I used interfaces because they exist and intuively make sense, and support classes because why not. Otherwise it could be just structs and other values with candidate UFCS 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.

Using an interface means using familiar syntax with the added benefits of being able to write a signature like this:

int* fun(int*, int) @safe @nogc pure return scope const;

And then have all of those attributes and `this` modifiers used in the vtable function pointer declarations. Overloading and UFCS get dealt with naturally by usual language rules.

Reply via email to