Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Eloy Bote Falcon
2009/11/19 Mathieu Suen > Eloy Bote Falcon a écrit : > > 2009/11/18 Mathieu Suen >> >> Etienne Kneuss a écrit : >>> >>> Hello, >>> On Wed, Nov 18, 2009 at 5:54 PM, Mathieu Suen < mathieu.s...@easyflirt.com > wrote: > Robert Lemke a écrit : > Hi folks, >

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Mathieu Suen
Alban a écrit : Le Thu, 19 Nov 2009 02:24:01 +, Jared Williams a écrit : -Original Message- From: Robert Lemke [mailto:rob...@typo3.org] Sent: 18 November 2009 16:07 To: internals@lists.php.net Subject: [PHP-DEV] RFC: Custom Factories (SPL) Hi folks, after discussing the idea with

[PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Alexis Métaireau
Hello here! I'm a big fan of IoC too, and I think that PHP devs really need to have a look into Inversion of control. Adding this feature to PHP can be useful for providing a simple way to detect and manage the object creation process. The "spl_factory_register" function allows to specify a manne

[PHP-DEV] Question about buffer size calculation in _php_stream_copy_to_mem_ex

2009-11-19 Thread Arvind Srinivasan
I see the following in _php_stream_copy_to_mem_ex in main/streams/streams.c int step = CHUNK_SIZE; int min_room = CHUNK_SIZE / 4; (..stuff deleted..) /* avoid many reallocs by allocating a good sized chunk to begin with, if * we can. Note that the strea

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Ionut G. Stan
This smells like metaclasses to me, just that in your RFC they are supposed to work on a global level, not on a per class level. Python, for example, has a magic method called `__new__`, which controls the creation of the object whenever a new class is instantiated. It actually allows you to r

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Mathieu Suen
Ionut G. Stan a écrit : This smells like metaclasses to me, just that in your RFC they are supposed to work on a global level, not on a per class level. Python, for example, has a magic method called `__new__`, which controls the creation of the object whenever a new class is instantiated. It

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Ionut G. Stan
It will work, just in a very complicated way. Emailer would need to have access to some other global variables in order to resolve its dependencies. My point is that they are globals. On 11/19/2009 4:57 PM, Mathieu Suen wrote: Ionut G. Stan a écrit : This smells like metaclasses to me, just t

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Ionut G. Stan
One could just as well pass an instance of Emailer to the constructor. It's the same thing, except that it's less code (and it's easier to understand in my opinion). It's a basic application of the Law of Demeter. On 11/18/2009 7:19 PM, Mathieu Suen wrote: Right!! I get confused with: $class

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Mathieu Suen
Ionut G. Stan a écrit : One could just as well pass an instance of Emailer to the constructor. It's the same thing, except that it's less code (and it's easier to understand in my opinion). That is type 3 IoC. It's a basic application of the Law of Demeter. I don't see the point with "th

Re: [PHP-DEV] Closures and $this

2009-11-19 Thread Jelrik van Hal
Victor Bolshov wrote: Hi. Personally, I beleive that (A) approach is the best: "bind $this to the object scope at creation" and never change it, issue error when $this is used where not available. It also seems to me like this way it could be implemented with better performance, am I right? Dyn

Re: [PHP-DEV] RFC: Custom Factories (SPL)

2009-11-19 Thread Alban
Le Thu, 19 Nov 2009 12:06:19 +0100, Mathieu Suen a écrit : > Alban a écrit : >> Le Thu, 19 Nov 2009 02:24:01 +, Jared Williams a écrit : >> -Original Message- From: Robert Lemke [mailto:rob...@typo3.org] Sent: 18 November 2009 16:07 To: internals@lists.php.net

Re: [PHP-DEV] The inconsistencies/flaws of PHP5's object model

2009-11-19 Thread Stanislav Malyshev
Hi! $methodName)) instead, which is ugly and verbose. Since PHP 5.3 adds closure support, I think the syntax "$o->f()" should also check whether "f" is a closure, if it is, then call it. That creates a myriad of problems due to the fact that if the class defines both __call and __get it is n

Re: [PHP-DEV] Closures and $this

2009-11-19 Thread Stanislav Malyshev
Hi! If php-people really would like rebinding $this, I beleive this should be done via method like Closure->bindTo() - to make the fact of rebinding clear in the code. However, there is a problem with rebinding $this - that was not mentioned yet, I think. This can be a problem, but since PHP

Re: [PHP-DEV] The inconsistencies/flaws of PHP5's object model

2009-11-19 Thread Julien Pauli
On Wed, Nov 18, 2009 at 8:59 PM, Stanislav Malyshev wrote: > Hi! > >> I've just occured a syntax problem in the following script: >> >> > class C { >>    public $n = 1; >> } >> $o = new C(); >> $o->f = function () use ($o) { >>    echo $o->n; >> }; >> $o->f(); >> ?> >> >> The result of this script

Re: [PHP-DEV] The inconsistencies/flaws of PHP5's object model

2009-11-19 Thread Stanislav Malyshev
Hi! call_user_func(array($o,'f')); leads to fatal error, I think the same Of course, since you again asked to call method 'f'. Try: call_user_func($o->f); -- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP Internals -

Re: [PHP-DEV] The inconsistencies/flaws of PHP5's object model

2009-11-19 Thread Stanislav Malyshev
Hi! call_user_func(array($o,'f')); leads to fatal error, I think the same Of course, since you again asked to call method 'f'. Try: call_user_func($o->f); Ah, didn't notice you already wrote that. Anyway, the difference is that methods and properties in PHP, unlike Javascript, live in diffe

[PHP-DEV] clarification on maximum string sizes in PHP on 64 bit linux

2009-11-19 Thread Matt Wirges
Folks, I'm hoping someone can clarify for me the limitations that PHP 5.2/5.3/6.0 is expected to put on the size of strings on 64 bit linux. The php manual documentation for the string type makes the following note about string size: "Note: It is no problem for a string to become very large. PHP

[PHP-DEV] Re: clarification on maximum string sizes in PHP on 64 bit linux

2009-11-19 Thread jvlad
> Code: > $s = str_repeat('A', pow(2,30)); > $t = $s.str_repeat('B', pow(2,30));; // fails with segfault > printf("strlen: %u last-char: %s", strlen($s), substr($s, pow(2,30)-1)); > ?> > --- > Result: > ./sapi/cli/php -d memory_limit=-1 a2.php > > Fatal error: Out of memory (allocated 2148270080)

[PHP-DEV] Proposed 5.3.1 Release announcement

2009-11-19 Thread Johannes Schlüter
The PHP development team would like to announce the immediate availability of PHP 5.3.1. This release focuses on improving the stability of the PHP 5.3.x branch with over 100 bug fixes, some of which are security related. All users are encouraged to upgrade to this release. Security Enh

[PHP-DEV] Re: Custom Factories (SPL)

2009-11-19 Thread jvlad
> Hi folks, > > after discussing the idea with various PHP developers > I now felt safe enough that it's not a completely stupid > idea to post an RFC for it. The idea is to add support > the registration of > custom factories which are > responsible for instantiating certain classes. > > Here is

[PHP-DEV] 5.3.1 Release announcement

2009-11-19 Thread Johannes Schlüter
The PHP development team would like to announce the immediate availability of PHP 5.3.1. This release focuses on improving the stability of the PHP 5.3.x branch with over 100 bug fixes, some of which are security related. All users are encouraged to upgrade to this release. Security Enh

Re: [PHP-DEV] Re: clarification on maximum string sizes in PHP on 64 bit linux

2009-11-19 Thread Matt Wirges
On Thu, Nov 19, 2009 at 4:52 PM, jvlad wrote: >> Code: >> > $s = str_repeat('A', pow(2,30)); >> $t = $s.str_repeat('B', pow(2,30));; // fails with segfault >> printf("strlen: %u last-char: %s", strlen($s), substr($s, pow(2,30)-1)); >> ?> >> --- >> Result: >> ./sapi/cli/php -d memory_limit=-1 a2.ph

Re: [PHP-DEV] Closures and $this

2009-11-19 Thread Victor Bolshov
Hello. Jelrik, I could easily show a real-world example where using $this in closures could help. Consider Person class which has to verify that email address is unique. Suppose we have validation code in a single place and filter_var_array() is used to check all the data: class Person { .. f

Re: [PHP-DEV] Closures and $this

2009-11-19 Thread Victor Bolshov
Hi > so you can with $foo->$bar() or $foo() You're talking about variable functions/methods. But that is not the subject of discussion. Variable functions/methods are useful but introduce mess. This is well-known and this feature exists in PHP for a long time - so everybody should be condidered a

[PHP-DEV] Bug tracker cannot connect to database

2009-11-19 Thread Edward Z. Yang
I don't know if this is the right list to report to, but bugs.php.net is currently non-functional. Cheers, Edward -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php