Re: [PHP-DEV] static constructor

2015-03-15 Thread Christoph Becker
Johannes Ott wrote: I tried to get some RFC karma for my wiki account, following those lines: Email internals@lists.php.net requesting RFC karma for your wiki account. In the email, remind people about the RFC you plan to create. Note that RFC karma does not automatically give you karma to

Re: [PHP-DEV] static constructor

2015-03-15 Thread Crypto Compress
I think I now get the misunderstanding I had on your destructor question Sorry for confusion. My points are agnostic about implementation details and concrete code. It's up to ppl to use this feature as they like. - first point is a logical conclusion: If there is a cctor, there should be

Re: [PHP-DEV] static constructor

2015-03-15 Thread Johannes Ott
Am 15.03.2015 um 11:02 schrieb Crypto Compress: I think I now get the misunderstanding I had on your destructor question Sorry for confusion. My points are agnostic about implementation details and concrete code. It's up to ppl to use this feature as they like. Okay get your point, but

Re: [PHP-DEV] static constructor

2015-03-15 Thread Johannes Ott
Am 13.03.2015 um 01:33 schrieb Christoph Becker: Johannes Ott wrote: And i although see no DI or Singleton pattern to use here to get the same functionality, if you want to use like Config::getHostname() and not like Config::getInstance()-getHostname() which is really unnecessary

Re: [PHP-DEV] static constructor

2015-03-15 Thread Johannes Ott
Am 15.03.2015 um 19:47 schrieb Rowan Collins: On 15/03/2015 10:41, Johannes Ott wrote: Okay get your point, but as already discussed several times, the rfc should not be declined for the reason a ppl, who doesn't understand when to use static context or when not to use at all, can do crucial

Re: [PHP-DEV] static constructor

2015-03-15 Thread Rowan Collins
On 15/03/2015 10:41, Johannes Ott wrote: Okay get your point, but as already discussed several times, the rfc should not be declined for the reason a ppl, who doesn't understand when to use static context or when not to use at all, can do crucial things. Because he although can do without the

Re: [PHP-DEV] static constructor

2015-03-15 Thread Johannes Ott
Am 15.03.2015 um 12:35 schrieb Crypto Compress: You should reread your mails and keep insults to yourself: as already discussed several times ppl, who doesn't understand some beginner who is doing such horiffic code maybe think more about what he is doing doing 15 years of

Re: [PHP-DEV] static constructor

2015-03-15 Thread Rowan Collins
On 15/03/2015 20:52, Johannes Ott wrote: Am 15.03.2015 um 19:47 schrieb Rowan Collins: On 15/03/2015 10:41, Johannes Ott wrote: Okay get your point, but as already discussed several times, the rfc should not be declined for the reason a ppl, who doesn't understand when to use static context or

Re: [PHP-DEV] static constructor

2015-03-14 Thread Johannes Ott
Am 14.03.2015 um 18:34 schrieb Crypto Compress: So I do not see the need of a explicit class deconstructor, because the language should already react correctly on this issues as I can see so far The language cannot know the order of dependencies and how to destruct them. A dependcy between

Re: [PHP-DEV] static constructor

2015-03-14 Thread Johannes Ott
Am 14.03.2015 um 18:34 schrieb Crypto Compress: So I do not see the need of a explicit class deconstructor, because the language should already react correctly on this issues as I can see so far The language cannot know the order of dependencies and how to destruct them. A dependcy between

Re: [PHP-DEV] static constructor

2015-03-14 Thread Crypto Compress
Am 13.03.2015 um 11:30 schrieb Johannes Ott: Am 13.03.2015 um 07:45 schrieb Crypto Compress: Hello Johannes, in other mails you argue with Rowan about global state. I think it's better to focus on innovation of class context in global scope, as it's impossible to reason the disadvantages of

Re: [PHP-DEV] static constructor

2015-03-14 Thread Crypto Compress
So I do not see the need of a explicit class deconstructor, because the language should already react correctly on this issues as I can see so far The language cannot know the order of dependencies and how to destruct them. A dependcy between destructors of instances, which the language have

Re: [PHP-DEV] static constructor

2015-03-14 Thread Johannes Ott
Am 14.03.2015 um 07:49 schrieb Crypto Compress: Am 13.03.2015 um 11:30 schrieb Johannes Ott: Am 13.03.2015 um 07:45 schrieb Crypto Compress: Hello Johannes, in other mails you argue with Rowan about global state. I think it's better to focus on innovation of class context in global scope, as

Re: [PHP-DEV] static constructor

2015-03-13 Thread Rowan Collins
Johannes Ott wrote on 13/03/2015 15:35: I think as Christoph wrote we should now do a cut here for the inital discussion, because we are in a circle now. I will now get on at the RFC process, and will prepare the RFC-draft asap. I will try to summarize as good as possible all discussion points

Re: [PHP-DEV] static constructor

2015-03-13 Thread Crypto Compress
Hello Johannes, in other mails you argue with Rowan about global state. I think it's better to focus on innovation of class context in global scope, as it's impossible to reason the disadvantages of global state away. (Discussions on variable scope are painful too.) And two questions: 1. By

Re: [PHP-DEV] static constructor

2015-03-13 Thread Johannes Ott
Am 13.03.2015 um 01:33 schrieb Christoph Becker: Johannes Ott wrote: And i although see no DI or Singleton pattern to use here to get the same functionality, if you want to use like Config::getHostname() and not like Config::getInstance()-getHostname() which is really unnecessary

Re: [PHP-DEV] static constructor

2015-03-13 Thread Rowan Collins
Johannes Ott wrote on 12/03/2015 23:36: Am 12.03.2015 um 21:33 schrieb Rowan Collins: Johannes Ott wrote on 12/03/2015 19:45: All of the magic methods are doing like this. I thought you might say that, but the only thing remotely similar I can think of is a destructor, which gets called

Re: [PHP-DEV] static constructor

2015-03-13 Thread Rowan Collins
Johannes Ott wrote on 13/03/2015 09:53: Am 13.03.2015 um 01:33 schrieb Christoph Becker: Johannes Ott wrote: And i although see no DI or Singleton pattern to use here to get the same functionality, if you want to use like Config::getHostname() and not like Config::getInstance()-getHostname()

Re: [PHP-DEV] static constructor

2015-03-13 Thread Johannes Ott
Am 13.03.2015 um 14:36 schrieb Rowan Collins: Sorry, replying to myself to add a couple of thoughts / clarifications: Rowan Collins wrote on 13/03/2015 11:53: Johannes Ott wrote on 13/03/2015 09:53: Why are in your opinion static members are not allowed to hold more complexe datastructures

Re: [PHP-DEV] static constructor

2015-03-13 Thread Rowan Collins
Sorry, replying to myself to add a couple of thoughts / clarifications: Rowan Collins wrote on 13/03/2015 11:53: Johannes Ott wrote on 13/03/2015 09:53: Why are in your opinion static members are not allowed to hold more complexe datastructures then simple scalars? Complex data structures,

Re: [PHP-DEV] static constructor

2015-03-12 Thread Alexey Zakhlestin
On 12 Mar 2015, at 02:21, Johannes Ott m...@deroetzi.de wrote: So now I want to do my first own proposal for a new function in PHP and I hope doing it right with starting a discussion here first. The purpose of this suggestion is to introduce a static constructor, which is called before

Re: [PHP-DEV] static constructor

2015-03-12 Thread Patrick Schaaf
On Thursday 12 March 2015 00:10:15 Rowan Collins wrote: On 11/03/2015 23:21, Johannes Ott wrote: The purpose of this suggestion is to introduce a static constructor, which is called before the first call to class either static or non-static to initialize some static properties which are

Re: [PHP-DEV] static constructor

2015-03-12 Thread Patrick Schaaf
On Thursday 12 March 2015 00:21:34 Johannes Ott wrote: The purpose of this suggestion is to introduce a static constructor, which is called before the first call to class either static or non-static to initialize some static properties which are needed by the class. We are doing this in our

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
What about inheritance? I think dynamic class-constructor would make much more sense. A function which can analyse real class and do initialisation. class A { protected static function __class_construct() { echo get_called_class().” class is defined\n; } }

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Am 12.03.2015 um 05:17 schrieb Levi Morrison: On Wed, Mar 11, 2015 at 6:10 PM, Rowan Collins rowan.coll...@gmail.com wrote: On 11/03/2015 23:21, Johannes Ott wrote: So now I want to do my first own proposal for a new function in PHP and I hope doing it right with starting a discussion here

Re: [PHP-DEV] static constructor

2015-03-12 Thread Crypto Compress
Hello Johannes, class Foo { private static function __static() { throw new Exception(boom); } } while(true) { try { $foo = new Foo; } catch (Exception ex) {} } Would this code be valid? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe,

Re: [PHP-DEV] static constructor

2015-03-12 Thread Crypto Compress
Am 12.03.2015 um 12:33 schrieb Johannes Ott: Am 12.03.2015 um 12:16 schrieb Crypto Compress: Hello Johannes, class Foo { private static function __static() { throw new Exception(boom); } } while(true) { try { $foo = new Foo; } catch (Exception ex) {} }

Re: [PHP-DEV] static constructor

2015-03-12 Thread Rowan Collins
Johannes Ott wrote on 12/03/2015 08:54: Am 12.03.2015 um 05:17 schrieb Levi Morrison: On Wed, Mar 11, 2015 at 6:10 PM, Rowan Collins rowan.coll...@gmail.com wrote: On 11/03/2015 23:21, Johannes Ott wrote: So now I want to do my first own proposal for a new function in PHP and I hope doing it

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Most of these examples are just crying out to be real objects, not static classes. You might not want to be creating them every time you use them, but that's what patterns like Singletons and Dependency Injection are for. I really disagree to this. Singletons are a typical

Re: [PHP-DEV] static constructor

2015-03-12 Thread Rowan Collins
Johannes Ott wrote on 12/03/2015 14:51: That is nearly like initializing a class constant, but in my opinion a constant should not have a complex algorithm (For example conditions or read from filesystem). That should be encapsulated inside a proper method body. I agree, but as such, I think

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Am 12.03.2015 um 12:40 schrieb Niklas Keller: How would it behave for the second call? If the first initialize fails due to some exception, should that static constructor be executed again? I think there a two different solutions and I do not know which one I prefer at the moment: 1. No

Re: [PHP-DEV] static constructor

2015-03-12 Thread Patrick Schaaf
Am 12.03.2015 17:28 schrieb Larry Garfield la...@garfieldtech.com: I thought it sounded familiar. Also check the list archive for A modest proposal: __constructStatic from a month ago. It was rejected then, too. That proposal was about a completely different issue. But you are right, it was

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Am 12.03.2015 um 16:57 schrieb Rowan Collins: Johannes Ott wrote on 12/03/2015 14:51: That is nearly like initializing a class constant, but in my opinion a constant should not have a complex algorithm (For example conditions or read from filesystem). That should be encapsulated inside a

Re: [PHP-DEV] static constructor

2015-03-12 Thread Alexey Zakhlestin
On 12 Mar 2015, at 19:28, Larry Garfield la...@garfieldtech.com wrote: I thought it sounded familiar. Also check the list archive for A modest proposal: __constructStatic from a month ago. It was rejected then, too. Really, I cannot think of any cases where I want to have a static

Re: [PHP-DEV] static constructor

2015-03-12 Thread Rowan Collins
Johannes Ott wrote on 12/03/2015 17:05: Am 12.03.2015 um 16:57 schrieb Rowan Collins: Johannes Ott wrote on 12/03/2015 14:51: That is nearly like initializing a class constant, but in my opinion a constant should not have a complex algorithm (For example conditions or read from filesystem).

Re: [PHP-DEV] static constructor

2015-03-12 Thread Rowan Collins
Johannes Ott wrote on 12/03/2015 19:45: All of the magic methods are doing like this. I thought you might say that, but the only thing remotely similar I can think of is a destructor, which gets called when an object goes out of scope; the others are all the implementation of, or instead

Re: [PHP-DEV] static constructor

2015-03-12 Thread Larry Garfield
On 3/12/15 10:57 AM, Rowan Collins wrote: Johannes Ott wrote on 12/03/2015 14:51: That is nearly like initializing a class constant, but in my opinion a constant should not have a complex algorithm (For example conditions or read from filesystem). That should be encapsulated inside a proper

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Am 12.03.2015 um 18:55 schrieb Rowan Collins: Johannes Ott wrote on 12/03/2015 17:05: Am 12.03.2015 um 16:57 schrieb Rowan Collins: Johannes Ott wrote on 12/03/2015 14:51: That is nearly like initializing a class constant, but in my opinion a constant should not have a complex algorithm (For

Re: [PHP-DEV] static constructor

2015-03-12 Thread Rowan Collins
Patrick Schaaf wrote on 12/03/2015 18:40: Am 12.03.2015 18:56 schrieb Rowan Collins rowan.coll...@gmail.com mailto:rowan.coll...@gmail.com: Johannes Ott wrote on 12/03/2015 17:05: So doing a null check each time is a overhead of calculation which can be avoided with this static

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Am 12.03.2015 um 20:34 schrieb Rowan Collins: Patrick Schaaf wrote on 12/03/2015 18:40: Am 12.03.2015 18:56 schrieb Rowan Collins rowan.coll...@gmail.com mailto:rowan.coll...@gmail.com: Johannes Ott wrote on 12/03/2015 17:05: So doing a null check each time is a overhead of

Re: [PHP-DEV] static constructor

2015-03-12 Thread Patrick Schaaf
Am 12.03.2015 18:56 schrieb Rowan Collins rowan.coll...@gmail.com: Johannes Ott wrote on 12/03/2015 17:05: So doing a null check each time is a overhead of calculation which can be avoided with this static constructor pattern. Presumably the engine would need to perform some implicit

Re: [PHP-DEV] static constructor

2015-03-12 Thread Patrick Schaaf
Am 12.03.2015 20:12 schrieb Dan Ackroyd dan...@basereality.com: Patrick Schaaf wrote: But that has proven, in the past, a fountain of joy wrt. placement, with variations needed for APC and opcache, and general frustration all around. Is there a bug report for the problems? OPCache

Re: [PHP-DEV] static constructor

2015-03-12 Thread Dan Ackroyd
Patrick Schaaf wrote: But that has proven, in the past, a fountain of joy wrt. placement, with variations needed for APC and opcache, and general frustration all around. Is there a bug report for the problems? OPCache shouldn't have side-effects on the code. cheers Dan On 12 March 2015 at

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Am 12.03.2015 um 21:33 schrieb Rowan Collins: Johannes Ott wrote on 12/03/2015 19:45: All of the magic methods are doing like this. I thought you might say that, but the only thing remotely similar I can think of is a destructor, which gets called when an object goes out of scope; the

Re: [PHP-DEV] static constructor

2015-03-12 Thread Christoph Becker
Johannes Ott wrote: And i although see no DI or Singleton pattern to use here to get the same functionality, if you want to use like Config::getHostname() and not like Config::getInstance()-getHostname() which is really unnecessary abstraction level for nothing in my opinion! It is possible,

Re: [PHP-DEV] static constructor

2015-03-12 Thread Rowan Collins
Patrick Schaaf wrote on 12/03/2015 08:40: On Thursday 12 March 2015 00:10:15 Rowan Collins wrote: On 11/03/2015 23:21, Johannes Ott wrote: The purpose of this suggestion is to introduce a static constructor, which is called before the first call to class either static or non-static to

Re: [PHP-DEV] static constructor

2015-03-12 Thread Johannes Ott
Am 12.03.2015 um 12:16 schrieb Crypto Compress: Hello Johannes, class Foo { private static function __static() { throw new Exception(boom); } } while(true) { try { $foo = new Foo; } catch (Exception ex) {} } Would this code be valid? Have to think

Re: [PHP-DEV] static constructor

2015-03-12 Thread Niklas Keller
2015-03-12 12:33 GMT+01:00 Johannes Ott m...@deroetzi.de: Am 12.03.2015 um 12:16 schrieb Crypto Compress: Hello Johannes, class Foo { private static function __static() { throw new Exception(boom); } } while(true) { try { $foo = new Foo; }

Re: [PHP-DEV] static constructor

2015-03-11 Thread Rowan Collins
On 11/03/2015 23:21, Johannes Ott wrote: So now I want to do my first own proposal for a new function in PHP and I hope doing it right with starting a discussion here first. The purpose of this suggestion is to introduce a static constructor, which is called before the first call to class

Re: [PHP-DEV] static constructor

2015-03-11 Thread Johannes Ott
Am 12.03.2015 um 00:30 schrieb Marco Pivetta: Hey Johannes, Why can't this be done at autoloading time? In my opinion this should not be done on autoloading time, but as a own method inside the class for two reasons. 1. Not every class is loaded with autoload-functions, but although directly

Re: [PHP-DEV] static constructor

2015-03-11 Thread Marco Pivetta
On 12 March 2015 at 00:21, Johannes Ott m...@deroetzi.de wrote: The purpose of this suggestion is to introduce a static constructor, which is called before the first call to class either static or non-static to initialize some static properties which are needed by the class. Hey Johannes,

Re: [PHP-DEV] static constructor

2015-03-11 Thread Levi Morrison
On Wed, Mar 11, 2015 at 6:10 PM, Rowan Collins rowan.coll...@gmail.com wrote: On 11/03/2015 23:21, Johannes Ott wrote: So now I want to do my first own proposal for a new function in PHP and I hope doing it right with starting a discussion here first. The purpose of this suggestion is to