AW: [PHP-DEV] [RFC:generics]

2016-04-30 Thread Robert Stoll
> > In this case I would suggest to use class A which leaves room > > open to define lower bounds later on > > IMHO that is bordering on unreadable - all those brackets are really > confusing and hard on the eyes. > I agree, it looks quite ugly :-) Therefore another suggestion: class A

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Dominic Grostate
Yes this makes perfect sense now. On 29 Apr 2016 6:44 p.m., "Mathieu Rochette" wrote: > > > On 04/29/2016 06:02 PM, Rowan Collins wrote: > > Hi Dominic, > > > > Sorry, I think this may have got sent too early by mistake; please > > ignore the duplicate! > > > > Also, it's

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Mathieu Rochette
On 04/29/2016 06:02 PM, Rowan Collins wrote: > Hi Dominic, > > Sorry, I think this may have got sent too early by mistake; please > ignore the duplicate! > > Also, it's crossed in the post with your next message, but I'll send > it anyway, in case it helps anyone understand. > > > Dominic

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Rowan Collins
Dominic Grostate wrote on 29/04/2016 17:45: This means then that to use a subtype for the type argument, it is safe for the function to READ the argument, but unsafe to WRITE to it. Conversely. If the function accepted List, but was theoretically given List, WRITING would be safe, but

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Dominic Grostate
This means then that to use a subtype for the type argument, it is safe for the function to READ the argument, but unsafe to WRITE to it. Conversely. If the function accepted List, but was theoretically given List, WRITING would be safe, but READING wouldn't. Given this, it doesn't matter how

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Jesse Schalken
On Sat, Apr 30, 2016 at 12:26 AM, guilhermebla...@gmail.com < guilhermebla...@gmail.com> wrote: > Wrong. This is documented here > https://docs.oracle.com/javase/tutorial/java/generics/upperBounded.html > and specifically states: > > To write the method that works on lists of Number and the

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Rowan Collins
Dominic Grostate wrote on 29/04/2016 16:59: After reading your email again, I find myself agreeing. This is because I don't consider List to be a subtype of List. LinkedList would be a subtype of List, but inheritance doesn't really extend any further beyond that, for the reason you have

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Rowan Collins
Hi Dominic, Sorry, I think this may have got sent too early by mistake; please ignore the duplicate! Also, it's crossed in the post with your next message, but I'll send it anyway, in case it helps anyone understand. Dominic Grostate wrote on 29/04/2016 16:45: It's not insane, it's liskov

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Dominic Grostate
After reading your email again, I find myself agreeing. This is because I don't consider List to be a subtype of List. LinkedList would be a subtype of List, but inheritance doesn't really extend any further beyond that, for the reason you have illustrated. The example you gave is similar to

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Rowan Collins
Dominic Grostate wrote on 29/04/2016 16:45: It's not insane, it's liskov substitution. But that is an insane example, typical of Java to create a type that extends it's parent by adding value constraints.. directly violating the principle. Read the example again, and translate it into

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Dominic Grostate
It's not insane, it's liskov substitution. But that is an insane example, typical of Java to create a type that extends it's parent by adding value constraints.. directly violating the principle. On 29 Apr 2016 4:22 p.m., "Rowan Collins" wrote: guilhermebla...@gmail.com

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Rowan Collins
guilhermebla...@gmail.com wrote on 29/04/2016 15:26: You can add subtypes of A to a List in Java. What List >means is that the list itself may be a list of any type, provided that type >is compatible with A. So if B extends A, List is compatible with Listextends A>, and when reading items you

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread guilhermebla...@gmail.com
it as it doesn't fully >>> support polymorphism. >>> >>> 6- Reflection >>> >>> We discussed over an example I extracted from a piece of code I currently >>> work on. We came with several ideas, but couldn't wrap up (but we're >>> 80%)

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread guilhermebla...@gmail.com
https://gist.github.com/guilhermeblanco/56ec0e11e7b029c2cfdcaf6fe2323742 >> >> >> >> >> So I'll have to say sorry for poking around of "missing implementation" >> while in reality most of them cannot be applied in the context of PHP. >> I've re

Re: [PHP-DEV] [RFC:generics]

2016-04-29 Thread Jesse Schalken
- > > > Von: Rasmus Schultz [mailto:ras...@mindplay.dk] > > > Gesendet: Montag, 25. April 2016 18:09 > > > An: Josh Di Fabio > > > Cc: Dominic Grostate; Guilherme Blanco; Mathieu Rochette; Ben Scholzen > > 'DASPRiD'; Sara Golemon; PHP internals; Mathieu > > > R

Re: [PHP-DEV] [RFC:generics]

2016-04-27 Thread Rasmus Schultz
nco; Mathieu Rochette; Ben Scholzen >> 'DASPRiD'; Sara Golemon; PHP internals; Mathieu >> Rochette >> Betreff: Re: [PHP-DEV] [RFC:generics] >> >> > I really don't like 'as' in this context, even if Hack uses it, as it >> > doesn't reflect in English terms wha

Re: [PHP-DEV] [RFC:generics]

2016-04-27 Thread Rasmus Schultz
toll <p...@tutteli.ch> wrote: >> >> >> >> > -Ursprüngliche Nachricht- >> > Von: Rasmus Schultz [mailto:ras...@mindplay.dk] >> > Gesendet: Montag, 25. April 2016 18:09 >> > An: Josh Di Fabio >> > Cc: Dominic Grostate; Gu

Re: [PHP-DEV] [RFC:generics]

2016-04-26 Thread Jesse Schalken
> > -Ursprüngliche Nachricht- > > > Von: Rasmus Schultz [mailto:ras...@mindplay.dk] > > > Gesendet: Montag, 25. April 2016 18:09 > > > An: Josh Di Fabio > > > Cc: Dominic Grostate; Guilherme Blanco; Mathieu Rochette; Ben Scholzen > > 'DASP

Re: [PHP-DEV] [RFC:generics]

2016-04-26 Thread Dominic Grostate
ndet: Montag, 25. April 2016 18:09 > > An: Josh Di Fabio > > Cc: Dominic Grostate; Guilherme Blanco; Mathieu Rochette; Ben Scholzen > 'DASPRiD'; Sara Golemon; PHP internals; Mathieu > > Rochette > > Betreff: Re: [PHP-DEV] [RFC:generics] > > > > > I really d

Re: [PHP-DEV] [RFC:generics]

2016-04-26 Thread guilhermebla...@gmail.com
> > -Ursprüngliche Nachricht- > > Von: Rasmus Schultz [mailto:ras...@mindplay.dk] > > Gesendet: Montag, 25. April 2016 18:09 > > An: Josh Di Fabio > > Cc: Dominic Grostate; Guilherme Blanco; Mathieu Rochette; Ben Scholzen > 'DASPRiD'; Sara Golemon; PHP in

AW: [PHP-DEV] [RFC:generics]

2016-04-26 Thread Robert Stoll
ochette > Betreff: Re: [PHP-DEV] [RFC:generics] > > > I really don't like 'as' in this context, even if Hack uses it, as it > > doesn't reflect in English terms what the code is doing. As others > > have already said, it reads as if 'T' is being aliased to 'Bar'. > > I

Re: [PHP-DEV] [RFC:generics]

2016-04-25 Thread Rasmus Schultz
> I really don't like 'as' in this context, even if Hack uses it, as it > doesn't reflect in English terms what the code is doing. As others > have already said, it reads as if 'T' is being aliased to 'Bar'. I second that. I hear the concerns about adding another reserved word "is" though, so

Re: [PHP-DEV] [RFC:generics]

2016-04-21 Thread Larry Garfield
On 4/21/16 10:43 AM, Rowan Collins wrote: guilhermebla...@gmail.com wrote on 21/04/2016 16:25: I understand others mentioned we could create a new interface that wraps the other two interfaces, but that still doesn't solve the problem where I want to extend a class AND also implement a

Re: [PHP-DEV] [RFC:generics]

2016-04-21 Thread Dennis Birkholz
Hi all, Am 20.04.2016 um 16:44 schrieb guilhermebla...@gmail.com: > If I want to hire/move a person to a department that is registered in the > system, but is not a 3rd party company person, how would you achieve that > considering the following class structure? > > class Person {} > class

AW: [PHP-DEV] [RFC:generics]

2016-04-21 Thread Robert Stoll
Hi Rasmus > 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

Re: [PHP-DEV] [RFC:generics]

2016-04-21 Thread Rowan Collins
guilhermebla...@gmail.com wrote on 21/04/2016 16:25: I understand others mentioned we could create a new interface that wraps the other two interfaces, but that still doesn't solve the problem where I want to extend a class AND also implement a specific interface. I covered this case in my

Re: [PHP-DEV] [RFC:generics]

2016-04-21 Thread Dominic Grostate
Nope, it pretty much made perfect sense to me the first time. But you may get your wish in it going in with the proposal anyway as I don't think this RFC is going to make it in time for the 7.1 window. My crack at implementing it went bust when I realised I was adding too many execute globals.

Re: [PHP-DEV] [RFC:generics]

2016-04-21 Thread guilhermebla...@gmail.com
I see that some of you are confusing union types with intersecting types here. The idea is not an OR, but an AND. I'll repeat the same example again to try to exemplify what I mentioned: class AA {} interface B {} interface C {} class BB extends AA implements B {} class CC extends AA implements

Re: [PHP-DEV] [RFC:generics]

2016-04-21 Thread Rowan Collins
Jesse Schalken wrote on 21/04/2016 04:18: Sticking with your example for a moment, if the type parameter is an "int", then the only type that can /currently/ be expressed in the type language that is a subtype of "int" is "int", so it's not very useful /right now/. However, a possible

Re: [PHP-DEV] [RFC:generics]

2016-04-21 Thread Josh Di Fabio
On Wed, Apr 20, 2016 at 8:17 PM, Dominic Grostate wrote: > Thanks for you're input everyone. > > So far, we have read some ideas for handling upper bounds, or multiple there > of. > The preferred keywords appear to be either "as" or "instanceof". > > class Foo {} >

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Jesse Schalken
On Thu, Apr 21, 2016 at 8:56 AM, Rowan Collins wrote: > > I'm not quite sure what bounds would mean for anything other than classes > or interfaces. A generic type that specified that its type parameter must > be an int seems to me to be a non-generic type, because

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Mathieu Rochette
On 04/20/2016 09:17 PM, Dominic Grostate wrote: > Thanks for you're input everyone. > > So far, we have read some ideas for handling upper bounds, or multiple > there of. > The preferred keywords appear to be either "as" or "instanceof". > > class Foo {} > class Foo {} > > We would like to know

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Rowan Collins
On 20/04/2016 22:02, Jesse Schalken wrote: "instanceof" implies to me that the right hand side is a class/interface name, since that's what's expected with the "instanceof" operator, rather than a type. If I can do "Foo>" I would expect to be able to do "if ($t instanceof array) ...", but I

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Jesse Schalken
"instanceof" implies to me that the right hand side is a class/interface name, since that's what's expected with the "instanceof" operator, rather than a type. If I can do "Foo>" I would expect to be able to do "if ($t instanceof array) ...", but I can't. I think unless the "instanceof" operator

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Sara Golemon
On Wed, Apr 20, 2016 at 12:17 PM, Dominic Grostate wrote: > The preferred keywords appear to be either "as" or "instanceof". > > class Foo {} > class Foo {} > > We would like to know for sure then if everyone is largely against the > addition of an "is" keyword, in

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Ryan Pallas
On Wed, Apr 20, 2016 at 1:17 PM, Dominic Grostate < codekest...@googlemail.com> wrote: > Thanks for you're input everyone. > > So far, we have read some ideas for handling upper bounds, or multiple > there of. > The preferred keywords appear to be either "as" or "instanceof". > > class Foo {} >

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Dominic Grostate
Thanks for you're input everyone. So far, we have read some ideas for handling upper bounds, or multiple there of. The preferred keywords appear to be either "as" or "instanceof". class Foo {} class Foo {} We would like to know for sure then if everyone is largely against the addition of an

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Jesse Schalken
Yes, if you have "class Box" and T is used for two things, then "they must be of the same type, but they can be any same type and that type must at least be Boxable". It means that Box can use a T as a Boxable (call Boxable methods on it, etc). On Thu, Apr 21, 2016 at 1:12 AM, Larry Garfield

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Dominic Grostate
I agree on both points (technically). It would allow you to apply that restriction. I only advise against it to reduce the impact the initial implementation would have on the codebase, provided it is preferable to implement it in phases. As for inference. Rasmus and I have argued over that a

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Rowan Collins
guilhermebla...@gmail.com wrote on 20/04/2016 15:44: In a given class, I might want to only accept CacheDrivers that also support BulkOperations. How would I achieve that? Apologies if this has been refuted elsewhere, but AFAIK you can implement any intersection constraint, albeit slightly

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Rowan Collins
Larry Garfield wrote on 20/04/2016 16:12: On 4/20/16 10:01 AM, Rowan Collins wrote: guilhermebla...@gmail.com wrote on 20/04/2016 03:54: 1- Even though mentioned, I'd still use "extends" or "implements" instead of "is" (which would be a new pseudo-reserved keyword) to enforce data type

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread guilhermebla...@gmail.com
Sure, the usage of "instanceof" is an alternative to prevent declaring a new keyword. PHP doesn't have the same problem as Java does to enforce the first generic type information to be a class and others interfaces. So in this: class A {} interface B {} interface C {} class Foo {} Java required

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Larry Garfield
On 4/20/16 10:01 AM, Rowan Collins wrote: guilhermebla...@gmail.com wrote on 20/04/2016 03:54: 1- Even though mentioned, I'd still use "extends" or "implements" instead of "is" (which would be a new pseudo-reserved keyword) to enforce data type consistency and prevent developers to

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Rowan Collins
guilhermebla...@gmail.com wrote on 20/04/2016 03:54: 1- Even though mentioned, I'd still use "extends" or "implements" instead of "is" (which would be a new pseudo-reserved keyword) to enforce data type consistency and prevent developers to potentially referring to one thing while consider

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread guilhermebla...@gmail.com
I don't know if mid-thread answering may lead to top-posting, but if it does, I'm sorry... =\ Answer inline: On Wed, Apr 20, 2016 at 5:10 AM, Dominic Grostate < codekest...@googlemail.com> wrote: > I've made an amendment to the RFC to clarify on the Nested Types, which is > indeed supposed to

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Quim Calpe
On Wed, Apr 20, 2016 at 11:10 AM, Dominic Grostate < codekest...@googlemail.com> wrote: > I've made an amendment to the RFC to clarify on the Nested Types, which is > indeed supposed to be part of the feature. Rasmus may want to reword it if > it isn't very clear. > > Regarding union and

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Dominic Grostate
I've made an amendment to the RFC to clarify on the Nested Types, which is indeed supposed to be part of the feature. Rasmus may want to reword it if it isn't very clear. Regarding union and intersections for upper (and maybe lower) bounds. Would it be appropriate to exclude these from type

Re: [PHP-DEV] [RFC:generics]

2016-04-20 Thread Mathieu Rochette
On 20/04/2016 00:22, Sara Golemon wrote: On Tue, Apr 19, 2016 at 1:16 PM, Mathieu Rochette wrote: about the upper bounds, have you consider another way of describing the constraints, eg: class Box where T is Boxable this would allow multiple constraints, eg: class

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Jesse Schalken
I agree. On Wed, Apr 20, 2016 at 2:01 PM, Sara Golemon wrote: > On Tue, Apr 19, 2016 at 7:56 PM, Jesse Schalken > wrote: > >> class Collection {... > > > > I think the "where T is Traversable, T is Countable" syntax was intended > to > > represent the

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Sara Golemon
On Tue, Apr 19, 2016 at 7:56 PM, Jesse Schalken wrote: >> class Collection {... > > 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

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Sara Golemon
On Tue, Apr 19, 2016 at 7:54 PM, guilhermebla...@gmail.com wrote: > 1- Even though mentioned, I'd still use "extends" or "implements" instead of > "is" (which would be a new pseudo-reserved keyword) to enforce data type > consistency and prevent developers to

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Jesse Schalken
On Wed, Apr 20, 2016 at 8:22 AM, Sara Golemon wrote: > On Tue, Apr 19, 2016 at 1:16 PM, Mathieu Rochette > wrote: > > about the upper bounds, have you consider another way of describing the > > constraints, eg: > > > > class Box where T is Boxable > > > >

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread guilhermebla...@gmail.com
Hi, Here are a couple of comments towards Generics support to PHP. 1- Even though mentioned, I'd still use "extends" or "implements" instead of "is" (which would be a new pseudo-reserved keyword) to enforce data type consistency and prevent developers to potentially referring to one thing while

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Sara Golemon
On Tue, Apr 19, 2016 at 4:13 PM, Stanislav Malyshev wrote: >> class Collection {... > > I am sorry if this sounds harsh, but I really hope we won't have > something like this in PHP. Java templates are complex and weird enough, > adding another layer on top of that to allow

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Stanislav Malyshev
Hi! > class Collection {... I am sorry if this sounds harsh, but I really hope we won't have something like this in PHP. Java templates are complex and weird enough, adding another layer on top of that to allow type expressions IMHO is really taking it too far. -- Stas Malyshev

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Sara Golemon
On Tue, Apr 19, 2016 at 1:16 PM, Mathieu Rochette wrote: > about the upper bounds, have you consider another way of describing the > constraints, eg: > > class Box where T is Boxable > > this would allow multiple constraints, eg: > > class Collection where T is Traversable,

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Mathieu Rochette
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

Re: [PHP-DEV] [RFC:generics]

2016-04-19 Thread Dominic Grostate
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. Thanks. On 18 Apr 2016 11:24 a.m., "Josh Di Fabio"

Re: [PHP-DEV] [RFC:generics]

2016-04-18 Thread Josh Di Fabio
On Mon, Apr 18, 2016 at 10:47 AM, Josh Di Fabio wrote: > On Mon, Apr 18, 2016 at 6:20 AM, Rasmus Schultz wrote: >> Hello internals, >> >> I'd like to introduce an RFC proposing the addition of generic types >> and functions: >> >>

Re: [PHP-DEV] [RFC:generics]

2016-04-18 Thread Josh Di Fabio
On Mon, Apr 18, 2016 at 6:20 AM, Rasmus Schultz 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

[PHP-DEV] [RFC:generics]

2016-04-17 Thread Rasmus Schultz
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