Formal optional interfaces

jmh530 john.michael.hall at gmail.com
Tue Mar 5 21:55:22 UTC 2019


On Tuesday, 5 March 2019 at 20:03:30 UTC, Jacob Carlborg wrote:
> [snip]
>
> * Implement a __traits to check if an optional method is 
> implemented. It takes a type and a method signature:
>
> interface Foo
> {
>     @optional void foo();
> }
>
> struct Bar : Foo
> {
>     @implements void foo() { }
> }
> [snip]

What about with free-standing functions?

@impl void foo(Bar x) { }
or maybe would need to do
@impl!Foo void foo(Bar x) { }

This reminds me of open methods [1]

[1] https://dlang.org/blog/2017/08/28/open-methods-from-c-to-d/


More information about the Digitalmars-d mailing list