Re: [RFC:generics]
| From: | Jesse Schalken | Date: | Wed, 20 Apr 2016 02:56:27 +0000 |
| Subject: | Re: [RFC:generics] | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92516@lists.php.net to get a copy of this message | ||
On Wed, Apr 20, 2016 at 8:22 AM, Sara Golemon <pollita@php.net> wrote:
> On Tue, Apr 19, 2016 at 1:16 PM, Mathieu Rochette <mathieu@texthtml.net>
> wrote:
> > about the upper bounds, have you consider another way of describing the
> > constraints, eg:
> >
> > class Box<T> where T is Boxable
> >
> > this would allow multiple constraints, eg:
> >
> > class Collection<T> where T is Traversable, T is Countable
> >
> IMO, this sort of problem should be solved by combining this feature
> with union types, so you could have something like:
>
> class Collection<T as (Traversable | Countable)> {...
>
> And merely inherit the logic rules from that feature rather than
> inventing yet another one.
>
>
I think the "where T is Traversable, T is Countable" syntax was intended to
represent the intersection (i.e. a "Countable Traversable"), not the union.
So you would need an intersection syntax
class Collection<T as Traversable & Countable> {...
> > can generic types be nested ?
> >
> > class Stuff<A, B is Something<A, string>>
> >
> I can't imagine why not...
>
> For my part, I love the concept overall. Generics are an important
> part of moving PHP towards comprehensive type-safety. But then, you
> know how I feel about Hack. :)
>
> -Sara
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>