Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-11 Thread Lee Davis
Hi Phil. I really like this feature and am keen to see it go in. Developers often create classes (which are typically new files) just to extend and implement a small method. This feature could see codebases become much lighter. So a massive thanks for your and Joe’s efforts on this. I have tw

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-09 Thread Philip Sturgeon
Matthew, On Sun, Mar 8, 2015 at 11:04 PM, Matthew Leverton wrote: >>> $foo = class extends Callback { ... } >>> $bar = new $foo; >> >> Nope, none of that. Wrap that in a function or clone it perhaps. >> > Are you actively against that functionality? (I don't think it's very > useful, but was wond

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-08 Thread Thomas Bley
Just a question, can I do: $c = class { public static function square($i) { return $i*$i; } }); echo $c::square(42); or $c = class extends DateTime { public static function createFromFormat($translateFormat, $time) { $translateFormat = str_replace('foo', 'Y-m-d', $translateFormat)

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-08 Thread Philip Sturgeon
Patrick, On Sat, Mar 7, 2015 at 2:22 AM, Patrick Schaaf wrote: > > Am 06.03.2015 20:14 schrieb "Philip Sturgeon" : >> >> Right, this here RFC has been drastically improved. >> >> https://wiki.php.net/rfc/anonymous_classes >> >> Anyone got any doubts or troubles at this point? > > Can we / could w

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-08 Thread Philip Sturgeon
Stanislav, On Fri, Mar 6, 2015 at 6:42 PM, Stanislav Malyshev wrote: > Hi! > Couple of points to clarify: > > 1. Is the new syntax "new class ..." or just "class ..." and new works > the same? I.e. could you do: > > $foo = class extends Callback { ... } > $bar = new $foo; Nope, none of that. Wra

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-07 Thread Marcio Almada
Hi, 2015-03-07 8:28 GMT-03:00 Robert Stoll : > > > -Ursprüngliche Nachricht- > > Von: Patrick Schaaf [mailto:p...@bof.de] > > Gesendet: Samstag, 7. März 2015 08:22 > > An: Philip Sturgeon > > Cc: internals; Robert Stoll > > Betreff: Re: [PHP-

AW: [PHP-DEV] [RFC] Anonymous Classes

2015-03-07 Thread Robert Stoll
> -Ursprüngliche Nachricht- > Von: Patrick Schaaf [mailto:p...@bof.de] > Gesendet: Samstag, 7. März 2015 08:22 > An: Philip Sturgeon > Cc: internals; Robert Stoll > Betreff: Re: [PHP-DEV] [RFC] Anonymous Classes > > Am 06.03.2015 20:14 schrieb "Philip Sturgeo

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-07 Thread Lazare Inepologlou
2015-03-07 8:22 GMT+01:00 Patrick Schaaf : > Am 06.03.2015 20:14 schrieb "Philip Sturgeon" : > > > > Right, this here RFC has been drastically improved. > > > > https://wiki.php.net/rfc/anonymous_classes > > > > Anyone got any doubts or troubles at this point? > > Can we / could we do "extends sel

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-06 Thread Patrick Schaaf
Am 06.03.2015 20:14 schrieb "Philip Sturgeon" : > > Right, this here RFC has been drastically improved. > > https://wiki.php.net/rfc/anonymous_classes > > Anyone got any doubts or troubles at this point? Can we / could we do "extends self", "extends static", or even "extends $someclassname" ? The

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-06 Thread Yasuo Ohgaki
Hi all, On Wed, Feb 25, 2015 at 4:06 AM, S.A.N wrote: > Yes, is problem - properties and methods look the same, how to solve > this problem in PHP I do not know. > Perhaps PHP could interpret this code: > $object = > { > 'property' => $value, > 'method' => function (){...} > }; > > AS >

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-06 Thread Stanislav Malyshev
Hi! > Right, this here RFC has been drastically improved. > > https://wiki.php.net/rfc/anonymous_classes > > Anyone got any doubts or troubles at this point? > > It's about 5 days until the vote starts. Couple of points to clarify: 1. Is the new syntax "new class ..." or just "class ..." and

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-06 Thread Philip Sturgeon
Right, this here RFC has been drastically improved. https://wiki.php.net/rfc/anonymous_classes Anyone got any doubts or troubles at this point? It's about 5 days until the vote starts. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

AW: [PHP-DEV] [RFC] Anonymous Classes

2015-03-04 Thread Robert Stoll
> -Ursprüngliche Nachricht- > Von: Philip Sturgeon [mailto:pjsturg...@gmail.com] > Gesendet: Mittwoch, 4. März 2015 16:49 > An: Robert Stoll > Cc: PHP Internals > Betreff: Re: [PHP-DEV] [RFC] Anonymous Classes > > On Tue, Mar 3, 2015 at 12:03 PM, Robert Sto

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-03-04 Thread Philip Sturgeon
On Tue, Mar 3, 2015 at 12:03 PM, Robert Stoll wrote: > Hi Philip > >> -Ursprüngliche Nachricht- >> Von: Philip Sturgeon [mailto:pjsturg...@gmail.com] >> Gesendet: Dienstag, 24. Februar 2015 14:52 >> An: PHP Internals >> Betreff: [PHP-DEV] [R

AW: [PHP-DEV] [RFC] Anonymous Classes

2015-03-03 Thread Robert Stoll
Hi Philip > -Ursprüngliche Nachricht- > Von: Philip Sturgeon [mailto:pjsturg...@gmail.com] > Gesendet: Dienstag, 24. Februar 2015 14:52 > An: PHP Internals > Betreff: [PHP-DEV] [RFC] Anonymous Classes > > Good day! > > https://wiki.php.net/rfc/anonymous_classe

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-25 Thread Philip Sturgeon
On Tue, Feb 24, 2015 at 2:25 PM, Stanislav Malyshev wrote: > Hi! > >> I like the idea of having anonymous classes, it is very helpful during >> development to just try something out without having the burden of >> creating a new file and a complete class including namespace and use >> declarations

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Stanislav Malyshev
Hi! > I like the idea of having anonymous classes, it is very helpful during > development to just try something out without having the burden of > creating a new file and a complete class including namespace and use > declarations, etc. I think this particular argument is a bit backwards. In PHP

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Stanislav Malyshev
Hi! > https://wiki.php.net/rfc/anonymous_classes > > There's a little RFC + patch that Joe Watkins put together, and as > before with the ArrayOf RFC, I'll be helping out. > > So, lets get this discussion rolling. This is a nice and clear proposal, however I'm not sure I'm completely convinced

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Thomas Bley
I'm not sure if json syntax is better than PHP here: $object = (object)[ 'property'=>$value, 'method'=>function(){...} ]; $object->property; $object->method->__invoke(); S.A.N wrote on 24.02.2015 19:37: > Would have been more useful, inline sintex like JSON: > > $object = > { >'propert

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread S.A.N
2015-02-24 20:49 GMT+02:00 Philip Sturgeon : > On Tue, Feb 24, 2015 at 1:37 PM, S.A.N wrote: >> Would have been more useful, inline sintex like JSON: >> >> $object = >> { >> 'property': $value, >> 'method': function (){...} >> }; >> >> $object->property; >> $object->method(); > > I know w

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Philip Sturgeon
On Tue, Feb 24, 2015 at 1:37 PM, S.A.N wrote: > Would have been more useful, inline sintex like JSON: > > $object = > { > 'property': $value, > 'method': function (){...} > }; > > $object->property; > $object->method(); I know what you're saying here, and object literals like this would

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread S.A.N
Would have been more useful, inline sintex like JSON: $object = { 'property': $value, 'method': function (){...} }; $object->property; $object->method(); -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Philip Sturgeon
On Tue, Feb 24, 2015 at 12:21 PM, Mike Willbanks wrote: > > > On Tue, Feb 24, 2015 at 7:52 AM, Philip Sturgeon > wrote: >> >> Good day! >> >> https://wiki.php.net/rfc/anonymous_classes >> >> There's a little RFC + patch that Joe Watkins put together, and as >> before with the ArrayOf RFC, I'll be

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Mike Willbanks
On Tue, Feb 24, 2015 at 7:52 AM, Philip Sturgeon wrote: > Good day! > > https://wiki.php.net/rfc/anonymous_classes > > There's a little RFC + patch that Joe Watkins put together, and as > before with the ArrayOf RFC, I'll be helping out. > > So, lets get this discussion rolling. > > It was declin

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Thomas Bley
here is an example for opening a mysqli connection only when the first query is executed: $c = new class extends mysqli { public function query($query, $resultmode = MYSQLI_STORE_RESULT) { if (empty($this->host_info)) parent::real_connect('127.0.0.1', 'user', 'pwd', 'db'); return paren

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Philip Sturgeon
On Tue, Feb 24, 2015 at 10:59 AM, Florian Anderiasch wrote: > On 02/24/2015 04:31 PM, Philip Sturgeon wrote: >> On Tue, Feb 24, 2015 at 9:58 AM, Florian Anderiasch >> wrote: >>> On 02/24/2015 03:29 PM, Dennis Birkholz wrote: Am 24.02.2015 um 14:52 schrieb Philip Sturgeon: > https://wiki

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Matthew Leverton
On Tue, Feb 24, 2015 at 7:52 AM, Philip Sturgeon wrote: > Good day! > > https://wiki.php.net/rfc/anonymous_classes > > There's a little RFC + patch that Joe Watkins put together, and as > before with the ArrayOf RFC, I'll be helping out. > > So, lets get this discussion rolling. > Anonymous classe

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Florian Anderiasch
On 02/24/2015 04:31 PM, Philip Sturgeon wrote: > On Tue, Feb 24, 2015 at 9:58 AM, Florian Anderiasch > wrote: >> On 02/24/2015 03:29 PM, Dennis Birkholz wrote: >>> Am 24.02.2015 um 14:52 schrieb Philip Sturgeon: https://wiki.php.net/rfc/anonymous_classes >>> >>> I like the idea of having ano

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Philip Sturgeon
On Tue, Feb 24, 2015 at 9:34 AM, Dmitry Stogov wrote: > > > On Tue, Feb 24, 2015 at 5:19 PM, Philip Sturgeon > wrote: >> >> On Tue, Feb 24, 2015 at 9:10 AM, Dmitry Stogov wrote: >> > I think the proposal is a bit incomplete. >> > It's possible to instantiate an anonymous class, but currently it'

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Philip Sturgeon
On Tue, Feb 24, 2015 at 9:58 AM, Florian Anderiasch wrote: > On 02/24/2015 03:29 PM, Dennis Birkholz wrote: >> Am 24.02.2015 um 14:52 schrieb Philip Sturgeon: >>> https://wiki.php.net/rfc/anonymous_classes >> >> I like the idea of having anonymous classes, it is very helpful during >> development

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Florian Anderiasch
On 02/24/2015 03:29 PM, Dennis Birkholz wrote: > Am 24.02.2015 um 14:52 schrieb Philip Sturgeon: >> https://wiki.php.net/rfc/anonymous_classes > > I like the idea of having anonymous classes, it is very helpful during > development to just try something out without having the burden of > creating

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Dmitry Stogov
On Tue, Feb 24, 2015 at 5:19 PM, Philip Sturgeon wrote: > On Tue, Feb 24, 2015 at 9:10 AM, Dmitry Stogov wrote: > > I think the proposal is a bit incomplete. > > It's possible to instantiate an anonymous class, but currently it's not > > possible to do with them anything else (assign to variable

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Dennis Birkholz
Hi Phil, Am 24.02.2015 um 14:52 schrieb Philip Sturgeon: > https://wiki.php.net/rfc/anonymous_classes I like the idea of having anonymous classes, it is very helpful during development to just try something out without having the burden of creating a new file and a complete class including namesp

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Philip Sturgeon
On Tue, Feb 24, 2015 at 9:10 AM, Dmitry Stogov wrote: > I think the proposal is a bit incomplete. > It's possible to instantiate an anonymous class, but currently it's not > possible to do with them anything else (assign to variable, pass to > function, etc). Something similar to Closure objects s

Re: [PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Dmitry Stogov
I think the proposal is a bit incomplete. It's possible to instantiate an anonymous class, but currently it's not possible to do with them anything else (assign to variable, pass to function, etc). Something similar to Closure objects should be introduced. Thanks. Dmitry. On Tue, Feb 24, 2015 at

[PHP-DEV] [RFC] Anonymous Classes

2015-02-24 Thread Philip Sturgeon
Good day! https://wiki.php.net/rfc/anonymous_classes There's a little RFC + patch that Joe Watkins put together, and as before with the ArrayOf RFC, I'll be helping out. So, lets get this discussion rolling. It was declined for PHP 5 some time ago, and has returned now to try for PHP 7. The us

Re: [PHP-DEV] RFC: Anonymous Classes

2013-10-01 Thread Joe Watkins
On 10/01/2013 01:19 PM, Terence Copestake wrote: On Fri, Sep 27, 2013 at 11:26 AM, Joe Watkins wrote: On 09/27/2013 10:42 AM, Terence Copestake wrote: Just ... Isn't that something, we can simply keep out of _this_ RFC and create separate RFC(s) for it later? Like it was done with "$this in

Re: [PHP-DEV] RFC: Anonymous Classes

2013-10-01 Thread Terence Copestake
On Fri, Sep 27, 2013 at 11:26 AM, Joe Watkins wrote: > On 09/27/2013 10:42 AM, Terence Copestake wrote: > >> Just ... Isn't that something, we can simply keep out of _this_ RFC and >>> create separate RFC(s) for it later? Like it was done with "$this in >>> Closures"? >>> >> >> >> Do we want anot

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-27 Thread Pierre Joye
hi Joe! On Thu, Sep 26, 2013 at 8:59 AM, Joe Watkins wrote: > Ok, I included just about all the information on use cases that is obvious > or has been discussed, so I think we got use cases covered now, right ?? Thanks for the updates! > See a good one yet ?? I think it should be enough, and

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-27 Thread Joe Watkins
On 09/27/2013 10:42 AM, Terence Copestake wrote: Just ... Isn't that something, we can simply keep out of _this_ RFC and create separate RFC(s) for it later? Like it was done with "$this in Closures"? Do we want another 5.3/5.4 closures situation? Why not iron it all out to begin with? If the

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-27 Thread Terence Copestake
> Just ... Isn't that something, we can simply keep out of _this_ RFC and > create separate RFC(s) for it later? Like it was done with "$this in > Closures"? Do we want another 5.3/5.4 closures situation? Why not iron it all out to begin with? If there's a sound, logical reason not to implement

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-27 Thread Sebastian Krebs
2013/9/27 Michael Wallner > On 27 September 2013 09:55, Nicolas Grekas > wrote: > > If you need access to the methods in AProxifier then why does the > anonymous > >> class extend A, you should extend AProxifier as you would with any other > >> class. > >> > > > > Because A has the behavior I wa

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-27 Thread Michael Wallner
On 27 September 2013 09:55, Nicolas Grekas wrote: > If you need access to the methods in AProxifier then why does the anonymous >> class extend A, you should extend AProxifier as you would with any other >> class. >> > > Because A has the behavior I want to extend? > > An other example: > > class

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-27 Thread Nicolas Grekas
If you need access to the methods in AProxifier then why does the anonymous > class extend A, you should extend AProxifier as you would with any other > class. > Because A has the behavior I want to extend? An other example: class A {...} class B {...} class Factory { protected function pro

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Alexander M
On Thu, Sep 26, 2013 at 5:59 PM, Joe Watkins wrote: > Ok, I included just about all the information on use cases that is obvious > or has been discussed, so I think we got use cases covered now, right ?? > > See a good one yet ?? > > > Cheers > Joe Wondering about scoping. Yes, anonymous classes

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Joe Watkins
On 09/26/2013 01:00 PM, Pierre Joye wrote: On Sep 26, 2013 10:35 AM, "Joe Watkins" wrote: Thanks ... I have made many changes to the RFC and patch since the beginning of this discussion ... It might be useful if you could all now go back to the RFC for another read, point out anythi

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Patrick Schaaf
Am 26.09.2013 12:16 schrieb "Joe Watkins" : > For the following reasons the syntax should remain as it is: > > It is consistent with anonymous function calls - args after definition ... I think it is exceedingly rare for anynomous functions to be called at their point of definition, while

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Pierre Joye
On Sep 26, 2013 10:35 AM, "Joe Watkins" wrote: > >> > > Thanks ... > > I have made many changes to the RFC and patch since the beginning of this discussion ... > > It might be useful if you could all now go back to the RFC for another read, point out anything I've left unclear at this point. I s

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Joe Watkins
On 09/26/2013 11:38 AM, Lazare Inepologlou wrote: 2013/9/26 Joe Watkins On 09/26/2013 01:50 AM, Pierre Joye wrote: hi! On Sun, Sep 22, 2013 at 11:39 PM, Joe Watkins wrote: Morning All, https://wiki.php.net/rfc/**anonymous_classes I'd like to

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Lazare Inepologlou
2013/9/26 Joe Watkins > On 09/26/2013 01:50 AM, Pierre Joye wrote: > >> hi! >> >> On Sun, Sep 22, 2013 at 11:39 PM, Joe Watkins wrote: >> >>> Morning All, >>> >>> https://wiki.php.net/rfc/**anonymous_classes >>> >>> I'd like to hear thoughts regarding

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Joe Watkins
On 09/26/2013 10:28 AM, Nicolas Grekas wrote: I think what Terence was talking about is more like this: class A { } class AProxifier { protected function protectedMethod() {...} function getAProxy() { return new class extends A { /* How do you call AProxifier->protected

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Patrick Schaaf
Am 26.09.2013 11:29 schrieb "Nicolas Grekas" : > Btw, I can't get used to ($val) beeing at the end of the declaration. I > feel it very confusing. I feel the same. Couldn't this (constructor arguments) be moved? $that = new class(/* constructor args */) /* extends X implements Y */ { ... class bo

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Nicolas Grekas
I think what Terence was talking about is more like this: class A { } class AProxifier { protected function protectedMethod() {...} function getAProxy() { return new class extends A { /* How do you call AProxifier->protectedMethod() here? */ }; } } This is possible with

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-26 Thread Joe Watkins
On 09/26/2013 01:50 AM, Pierre Joye wrote: hi! On Sun, Sep 22, 2013 at 11:39 PM, Joe Watkins wrote: Morning All, https://wiki.php.net/rfc/anonymous_classes I'd like to hear thoughts regarding the addition of anonymous classes, patch included. Thanks for your proposal and work. If you did

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-25 Thread Pierre Joye
hi! On Sun, Sep 22, 2013 at 11:39 PM, Joe Watkins wrote: > Morning All, > > https://wiki.php.net/rfc/anonymous_classes > > I'd like to hear thoughts regarding the addition of anonymous classes, > patch included. Thanks for your proposal and work. If you did not yet update your RFC I would sugge

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-25 Thread Joe Watkins
On 09/25/2013 02:02 PM, Terence Copestake wrote: 1) Anonymous classes in PHP would support a constructor, so I don't see the need for use to be utilized here, it would just clutter declarations and the patch. This works, but it's more effort for the programmer and arguably just moving the "clu

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-25 Thread Terence Copestake
> 1) Anonymous classes in PHP would support a constructor, so I don't see > the need for use to be utilized here, it would just clutter declarations > and the patch. This works, but it's more effort for the programmer and arguably just moving the "clutter" from the declaration to the constructor.

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-25 Thread Joe Watkins
On 09/25/2013 09:59 AM, Terence Copestake wrote: I'm growing to like the idea myself. It may create new opportunities for bad practices, but I don't think it's the concern of internals to police how people may or may not use a feature. There are also I think a few things that would need to be add

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-25 Thread Terence Copestake
I'm growing to like the idea myself. It may create new opportunities for bad practices, but I don't think it's the concern of internals to police how people may or may not use a feature. There are also I think a few things that would need to be addressed before this would be ready for the real worl

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Joe Watkins
On 09/24/2013 09:50 PM, Robert Stoll wrote: -Original Message- From: Joe Watkins [mailto:krak...@php.net] Sent: Tuesday, September 24, 2013 10:08 PM To: internals@lists.php.net; Kristopher Subject: Re: [PHP-DEV] RFC: Anonymous Classes On 09/24/2013 01:30 PM, Kristopher wrote: On Tue

RE: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Robert Stoll
> -Original Message- > From: Joe Watkins [mailto:krak...@php.net] > Sent: Tuesday, September 24, 2013 10:08 PM > To: internals@lists.php.net; Kristopher > Subject: Re: [PHP-DEV] RFC: Anonymous Classes > > On 09/24/2013 01:30 PM, Kristopher wrote: > > On T

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Joe Watkins
On 09/24/2013 01:30 PM, Kristopher wrote: On Tue, Sep 24, 2013 at 8:25 AM, Terence Copestake < terence.copest...@gmail.com> wrote: Playing devil's advocate here, could this feature make the language more expressive? Take for example an API where you'd typically wrap a method call in try/catch

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Pierre du Plessis
On 24 September 2013 14:51, Nicolas Grekas wrote: > What about allowing a "use" statement on these methods? > > $someFoo = "bar"; > > $object = new class{ > function method() use ($someFoo) { return $someFoo;} > } > > $object->method(); // "bar"; > I think the idea of anonymous classes is ve

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Nicolas Grekas
What about allowing a "use" statement on these methods? $someFoo = "bar"; $object = new class{ function method() use ($someFoo) { return $someFoo;} } $object->method(); // "bar";

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Kristopher
On Tue, Sep 24, 2013 at 8:25 AM, Terence Copestake < terence.copest...@gmail.com> wrote: > Playing devil's advocate here, could this feature make the language more > expressive? > > Take for example an API where you'd typically wrap a method call in > try/catch blocks to handle the various "outcom

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Terence Copestake
Playing devil's advocate here, could this feature make the language more expressive? Take for example an API where you'd typically wrap a method call in try/catch blocks to handle the various "outcomes" e.g. a user login, you'd maybe have a UserDisabled exception, a UserAlreadyLoggedIn exception,

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread Lazare Inepologlou
2013/9/24 David Soria Parra > Lazare Inepologlou schrieb: > > I use anonymous classes very frequently in Java and in C#, and I would > say > > that they are quite useful. However the examples given in the RFC are > > really bad ones. Why on earth would you need a constructor for an > anonymous >

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-24 Thread David Soria Parra
Lazare Inepologlou schrieb: > I use anonymous classes very frequently in Java and in C#, and I would say > that they are quite useful. However the examples given in the RFC are > really bad ones. Why on earth would you need a constructor for an anonymous > class? Anonymous classes are used to impl

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Lars Strojny
Hi Joe, Am 23.09.2013 um 19:22 schrieb Joe Watkins : [...] > As I have said, serialization does work, and unserialization does work ... > > Classes do have unique names, so as long as the entry is present upon > unserialize you will get the object you expect ... if the entry is not > present

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Adam Harvey
On 23 September 2013 08:03, Chris Wright wrote: > To summarize how I think this should be handled: Serialisation results in a > stdClass, unserialisation cannot be done because if you want it you're > already > Doing It WrongT. To me, serialising "successfully" would indicate that PHP could unser

RE: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Chris Wright
> What about UNserialize then? I don't see any way to handle this sensibly, but I also don't regard this as a problem, because that's not what these anonymous classes are for. If you want something that can be unserialised into a thing with methods then logically you know what it is ahead of time,

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Jakub Zelenka
Hi, On Sep 23, 2013 at 3:05 PM, Joe Watkins wrote: > On 09/23/2013 02:43 PM, Lars Strojny wrote: > >> Hi Joe, >> >> what about serialization for those classes? >> >> cu, >> Lars >> >> > Same as any other object; what you are creating is normal classes without > a (declared) name, nothing about t

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Sebastian Krebs
2013/9/23 Joe Watkins > On 09/23/2013 02:43 PM, Lars Strojny wrote: > >> Hi Joe, >> >> what about serialization for those classes? >> >> cu, >> Lars >> >> Am 23.09.2013 um 08:39 schrieb Joe Watkins : >> >> Morning All, >>> >>> >>> https://wiki.php.net/rfc/**anonymous_classes

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Patrick Schaaf
Am 23.09.2013 16:06 schrieb "Joe Watkins" : > > On 09/23/2013 02:43 PM, Lars Strojny wrote: >> >> what about serialization for those classes? > > Same as any other object; what you are creating is normal classes without a (declared) name, nothing about the objects functionality has differs from an

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Joe Watkins
On 09/23/2013 02:43 PM, Lars Strojny wrote: Hi Joe, what about serialization for those classes? cu, Lars Am 23.09.2013 um 08:39 schrieb Joe Watkins : Morning All, https://wiki.php.net/rfc/anonymous_classes I'd like to hear thoughts regarding the addition of anonymous classes, patc

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Lars Strojny
Hi Joe, what about serialization for those classes? cu, Lars Am 23.09.2013 um 08:39 schrieb Joe Watkins : > Morning All, > >https://wiki.php.net/rfc/anonymous_classes > >I'd like to hear thoughts regarding the addition of anonymous classes, > patch included. > > Cheers > Joe > > --

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Matthieu Napoli
Le 23/09/2013 10:39, Rasmus Lerdorf a écrit : On 09/22/2013 11:39 PM, Joe Watkins wrote: https://wiki.php.net/rfc/anonymous_classes I'd like to hear thoughts regarding the addition of anonymous classes, patch included. I am having a hard time picturing a real-world use-case for this

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Lazare Inepologlou
2013/9/23 Derick Rethans > On Mon, 23 Sep 2013, Joe Watkins wrote: > > > https://wiki.php.net/rfc/anonymous_classes > > This RFC misses one very important part: an argument for why this > feature is useful. Syntax changes are likely to be extremely contentious > and without convincingreasoning *w

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Michael Wallner
On 23 September 2013 10:39, Rasmus Lerdorf wrote: > On 09/22/2013 11:39 PM, Joe Watkins wrote: >> https://wiki.php.net/rfc/anonymous_classes >> >> I'd like to hear thoughts regarding the addition of anonymous >> classes, patch included. > > I am having a hard time picturing a real-world us

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Michael Wallner
On 23 September 2013 11:00, Michael Wallner wrote: > On 23 September 2013 10:39, Rasmus Lerdorf wrote: >> On 09/22/2013 11:39 PM, Joe Watkins wrote: >>> https://wiki.php.net/rfc/anonymous_classes >>> >>> I'd like to hear thoughts regarding the addition of anonymous >>> classes, patch incl

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Derick Rethans
On Mon, 23 Sep 2013, Joe Watkins wrote: > https://wiki.php.net/rfc/anonymous_classes This RFC misses one very important part: an argument for why this feature is useful. Syntax changes are likely to be extremely contentious and without convincingreasoning *why* we need this, we shouldn't even

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Marco Pivetta
On 23 September 2013 10:44, Sebastian Krebs wrote: > 2013/9/23 Rasmus Lerdorf > > > On 09/22/2013 11:39 PM, Joe Watkins wrote: > > > https://wiki.php.net/rfc/anonymous_classes > > > > > > I'd like to hear thoughts regarding the addition of anonymous > > > classes, patch included. > > > >

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Sebastian Krebs
2013/9/23 Rasmus Lerdorf > On 09/22/2013 11:39 PM, Joe Watkins wrote: > > https://wiki.php.net/rfc/anonymous_classes > > > > I'd like to hear thoughts regarding the addition of anonymous > > classes, patch included. > > I am having a hard time picturing a real-world use-case for this. >

Re: [PHP-DEV] RFC: Anonymous Classes

2013-09-23 Thread Rasmus Lerdorf
On 09/22/2013 11:39 PM, Joe Watkins wrote: > https://wiki.php.net/rfc/anonymous_classes > > I'd like to hear thoughts regarding the addition of anonymous > classes, patch included. I am having a hard time picturing a real-world use-case for this. -Rasmus -- PHP Internals - PHP Runtime

[PHP-DEV] RFC: Anonymous Classes

2013-09-22 Thread Joe Watkins
Morning All, https://wiki.php.net/rfc/anonymous_classes I'd like to hear thoughts regarding the addition of anonymous classes, patch included. Cheers Joe -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php