Re: [PHP-DEV] Generic classes and methods RFC

2015-09-15 Thread Stig Bakken
On Sep 12, 2015 16:57, "Andrea Faulds" wrote: > > > I'm with Levi here, I think type parameters should matter for static methods. An example might be a list class: > Just because you want it, doesn't make it possible ;-) The class type variables are specified when instantiating the class. Since

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-12 Thread Andrea Faulds
Hi Dennis, Dennis Birkholz wrote: Am 12.09.2015 um 12:03 schrieb Dennis Birkholz: Hi together, 1. If we require some keyword instead of the colon to limit which types the type placeholders can have I would choose: class Foo {} Just to save you some lookups in the Hack documentation: 1. Hack

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-12 Thread Andrea Faulds
Hey, Levi Morrison wrote: On Thu, Sep 10, 2015 at 5:12 PM, Ben Scholzen 'DASPRiD' wrote: Hi Dennis, thanks for your feedback, see my answers below: 1. static methods: class Foo { public static function test() { } } how can I call the method: a) Foo::test() or b) Foo::tes

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-12 Thread Levi Morrison
> 4. All type parameters must start with a capital T It's important to note that the HHVM runtime does not require this (or at least it didn't when I last checked it out). It's only the Hack type-checker that cares. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: h

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-12 Thread Dennis Birkholz
Am 12.09.2015 um 12:03 schrieb Dennis Birkholz: > Hi together, > > 1. If we require some keyword instead of the colon to limit which types > the type placeholders can have I would choose: > class Foo {} Just to save you some lookups in the Hack documentation: 1. Hack uses the "as" keyword: class

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-12 Thread Dennis Birkholz
Hi together, 1. If we require some keyword instead of the colon to limit which types the type placeholders can have I would choose: class Foo {} The C#-like syntax "where T1 extends Bla implements Blubb" (proposed in another thread) has two downsides: a) It will not fit nicely with generic method

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-11 Thread Ben Scholzen
What would prohibit this? class Factory { public static function makeFoo() { return new Foo(); } } It's perhaps less generic than what you posted, but this demonstrates that that a Factory *could* hold the definition on the class and not the method. To be

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-11 Thread Levi Morrison
(Please stop top-posting!) On Fri, Sep 11, 2015 at 10:55 AM, Ben Scholzen wrote: > Well, with the example, there's a good reason to have them separated: > > class Factory > { > public static function createFoo() > { > return new Foo(); > } > > public static function createBar() > {

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-11 Thread Ben Scholzen
Well, with the example, there's a good reason to have them separated: class Factory { public static function createFoo() { return new Foo(); } public static function createBar() { return new Bar(); } } class Foo {} class Bar {} The factory instance does not know to need abo

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-11 Thread Levi Morrison
On Fri, Sep 11, 2015 at 10:00 AM, Korvin Szanto wrote: > Levi, > It's my understanding that the "type variable" is a member of the instance > and not of the class. In at least java, generics are unavailable in static > context[1] though they can be specifically defined on the static method > itsel

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-11 Thread Korvin Szanto
Levi, It's my understanding that the "type variable" is a member of the instance and not of the class. In at least java, generics are unavailable in static context[1] though they can be specifically defined on the static method itself[2]. [1] http://stackoverflow.com/questions/936377/static-method

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-11 Thread Levi Morrison
On Thu, Sep 10, 2015 at 5:12 PM, Ben Scholzen 'DASPRiD' wrote: > Hi Dennis, > > thanks for your feedback, see my answers below: > >> 1. static methods: >> >> class Foo { >> public static function test() { >> } >> } >> >> how can I call the method: >> a) Foo::test() >> or >> b) Foo:

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-10 Thread Dennis Birkholz
Hi Ben, Am 31.08.2015 um 22:31 schrieb Ben Scholzen 'DASPRiD': > I've written up an RFC for supporting generic classes and methods in > PHP, and I'd love to hear your thoughts about it. > > https://wiki.php.net/rfc/generics I have some points where I think some clarification is required before s

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-10 Thread Ben Scholzen 'DASPRiD'
Hi Dennis, thanks for your feedback, see my answers below: 1. static methods: class Foo { public static function test() { } } how can I call the method: a) Foo::test() or b) Foo::test() in case b), would the generic methods not be a duplication? Case a) is correct here. A s

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-07 Thread Ben Scholzen
Hi, On 05.09.2015 21:48, John LeSueur wrote: Hi Ben, Now that I have substantive questions, including the list :) In the following: class SomeList { public static function fromArray(array $a): SomeList { $list = new SomeList(); $list2 = new SomeList(); return $

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-07 Thread Ben Scholzen
Hi, I would love to see generics in PHP, but I have a few questions for your RFC. class Bazz Why did you use this syntax for forcing extending/implementation? I know this is the syntax C# uses, but it doesn't fit PHP. I think it should be "extends" or "implements", because in PHP : has a differ

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-05 Thread John LeSueur
On Tue, Sep 1, 2015 at 2:54 AM, Pavel Kouřil wrote: > On Mon, Aug 31, 2015 at 10:31 PM, Ben Scholzen 'DASPRiD' > wrote: > > Hello, > > > > I've written up an RFC for supporting generic classes and methods in PHP, > > and I'd love to hear your thoughts about it. > > > > https://wiki.php.net/rfc/g

Re: [PHP-DEV] Generic classes and methods RFC

2015-09-01 Thread Pavel Kouřil
On Mon, Aug 31, 2015 at 10:31 PM, Ben Scholzen 'DASPRiD' wrote: > Hello, > > I've written up an RFC for supporting generic classes and methods in PHP, > and I'd love to hear your thoughts about it. > > https://wiki.php.net/rfc/generics > > Cheers, > -- > Ben Scholzen 'DASPRiD' > Community Review T

[PHP-DEV] Generic classes and methods RFC

2015-08-31 Thread Ben Scholzen 'DASPRiD'
Hello, I've written up an RFC for supporting generic classes and methods in PHP, and I'd love to hear your thoughts about it. https://wiki.php.net/rfc/generics Cheers, -- Ben Scholzen 'DASPRiD' Community Review Team Member | m...@dasprids.de Zend Framework | http://www.dasprids.