Hey all! Long time browser, first time emailer. I wanted to start a pre-RFC
discussion on the proposal of opt-in implicit interfaces / structural
typing / "golang style interfaces".

I have an early mostly working POC at
https://github.com/php/php-src/compare/master...SpencerMalone:php-src:implicit,
and was curious if this was an idea that could get any traction as an RFC?

For those who don't want to open the link, it's essentially:

```
implicit interface Drawable {
    public function draw(): void;
}

class Circle {
    public function draw(): void {
    }
}

assert((new Circle()) instanceof Drawable); // This would be true
```

There is some previous art around here in the form of...

https://wiki.php.net/rfc/protocol_type_hinting - I couldn't find any
discussion on this other than reading that the author withdrew all their
RFCs for unrelated reasons I think? Some of the core ideas here I think are
still relevant, although in my implementation I chose to use syntax that
adds a keyword onto the interface rather than at the call sites because I
wanted to provide the ability for interface definers to keep their
interfaces as explicit if they wanted, as well as... Well honestly, adding
angle brackets around objects feels like a syntax misstep since that
pattern is very associated with generics in my mind. I could be convinced
of this though if that's the syntax people prefer.

https://externals.io/message/115554#115603 - Convinced me that others may
want this as well, although again that proposed syntax ended up stepping on
the toes of attributes. I do think this does a good job of explaining _why_
I want this.

- Spencer

Reply via email to