On 20/04/2016 00:22, Sara Golemon wrote:
On Tue, Apr 19, 2016 at 1:16 PM, Mathieu Rochette <math...@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.
obviously if the union type rfc passes we don't need another way of expressing this. that was only in the case it does not, I think having a way to have at least types intersection
is useful here (and I didn't event think about <T is A & B>)

can generic types be nested ?

class Stuff<A, B is Something<A, string>>

I can't imagine why not...
just to be clear, it's not just nested generic. the A type have to be same in both "subtypes"

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

Reply via email to