Re: [Pre-RFC] Associated Types
On 22 April 2025 14:37:48 BST, "Gina P. Banyard" <[email protected]> wrote:
>Having talked with Arnaud off-list, it seems that using the "usual" generic syntax of
>(assuming our parser can cope with it):
>```
>interface I<T : int|string> {
> public function foo(T $param): T;
>}
>class CS implements I<string> {
> public function foo(string $param): string {
> return $param . '!';
> }
>}
>```
>is possible and would not conflict with any future proposal for generics.
I think if this works, it would be a really great step towards generics, where some use cases would
be possible, and some would have easier work arounds than today. Possibly we could slowly add places
the syntax is allowed, where we can make it make sense without tackling the tricky parts like
variance/inheritance and type inference.
Rowan Tommins
[IMSoP]
Thread (4 messages)