On 04/19/2016 06:28 PM, Dominic Grostate wrote: > We would really like some feedback on this. We know it is a massive > feature, but we have put in quite a lot of research in both the language > implications and implementation challenges. Please ask any questions you > have. thank you all for your work on this. That's a very interesting feature !
I guess it is possible but I have not seen it explicitly, can I do this: class StringKeyEntry<T> extends Entry<string,T> {} In "Traits" there is mistake; class Box<T> { use Box<T>; } should be class Box<T> { use Container<T>; } 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 { // ... } and, maybe, union type class Collection<T> where T is one of (\first\lib\Collection, \seconf\lib\Arrayable) { // ... } can generic types be nested ? eg: class Stuff<A, B is Something<A, string>> { // ... } considering the related enhancements, I guess this rfc is already big and both are useful enough to be proposed on their own. regards, > > Thanks. > On 18 Apr 2016 11:24 a.m., "Josh Di Fabio" <joshdifa...@gmail.com> wrote: > >> On Mon, Apr 18, 2016 at 10:47 AM, Josh Di Fabio <joshdifa...@gmail.com> >> wrote: >>> On Mon, Apr 18, 2016 at 6:20 AM, Rasmus Schultz <ras...@mindplay.dk> >> wrote: >>>> Hello internals, >>>> >>>> I'd like to introduce an RFC proposing the addition of generic types >>>> and functions: >>>> >>>> https://wiki.php.net/rfc/generics >>>> >>>> Ben Scholzen started this RFC as a quick draft with a few code samples >>>> in August last year, and I have since then worked with Dominic and >>>> Ben towards a more complete, detailed RFC. >>>> >>>> There are a few holes still, which is why it hasn't moved from Draft >>>> to Under Discussion yet, but we feel that it's complete enough that >>>> we can start a discussion about this feature and try to iron out >>>> the remaining details. >>>> >>>> The RFC was previously "unofficially" announced on reddit - this >>>> thread generated some good questions and may answer some of the >>>> most immediate questions: >>>> >>>> >> https://www.reddit.com/r/PHP/comments/3zx8qs/php_rfcgenerics_update_03_please_comment/ >>>> One of the most common criticisms we've heard, is that the syntax >>>> would be hard to implement, a few have said "impossible" - but we feel >>>> that, if generics are introduced, it's important that the syntax and >>>> features be as familiar as possible to developers who are experienced >>>> with other mainstream web industry languages, such as C# and Java. >>>> >>>> To that end, Dominic Grostate has worked through most of the >> tokenizer/parser >>>> issues - save for one very exotic edge case, his fork demonstrates that >> the >>>> proposed syntax can be parsed: >>>> >>>> https://github.com/orolyn/php-src/commits/generics >>>> >>>> Note that this fork is by no means an implementation of generics - it >> is proof >>>> of concept as far as being able to parse the syntax. >>>> >>>> We're hoping to find someone, with more experience working on the php >> codebase, >>>> who is willing to collaborate on further implementation - and we do >> also have >>>> a partial test-suite, defining the big picture expectations for most of >> the >>>> proposed language features: >>>> >>>> >> https://github.com/orolyn/php-src/tree/generics-tests/Zend/tests/generics >>>> We look forward to your comments, questions and (I'm sure) criticisms of >>>> this proposal! >>>> >>>> Thank You, >>>> >>>> Regards, >>>> Rasmus Schultz >>>> >>>> -- >>>> PHP Internals - PHP Runtime Development Mailing List >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>> >>> Nice work. >>> >>> I think you there's a typo in one of your examples: >>> >>> write(new Entry<int, int>(1, 2)); // throws a TypeError >>> >>> Presumably this should be <int, string> or something similar? >> Ignore me, I didn't read the example properly. >> -- Mathieu Rochette