Re: [PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object

2005-05-10 Thread Leonardo Pedretti
Not so chicken and egg if, through reflection, a ReflectionClass object could inform all the instances of that class in a simple array or with an iterator. May be there's another even better place where to implement such a functionality, i'm just pointing reflection because i think it's natural t

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Alex Knaub
2005/5/10, Sebastian Bergmann <[EMAIL PROTECTED]>: > Lukas Smith wrote: > > http://bugs.php.net/bug.php?id=30235 > > I agree with Marcus: self is bound at runtime, so the behaviour is > correct. If you do not like this late binding just do not use self but > the name of the class. I don't agre

Re: [PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object

2005-05-10 Thread Wez Furlong
Chicken and egg; you can't keep the object alive without a reference. There is no way to achieve what you want, and we're not going to change the behaviour of the new operator, nor are we going to build some kind of singleton factory thingy into the core language; you have the tools to do it "the r

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Lukas Smith
Ondrej IvaniÄ wrote: class SingletonFactory { private $instances; __construct() { $this->instances = array(); } function getInstance($name) { if(is_a($this->instances[$name], $name) === false) { $this->instances

[PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object

2005-05-10 Thread Leonardo Pedretti
How do i obtain the object again having just the key when i want to return it in another call, if i don't have a reference somewhere? The point would be: object asked id #1, it is not already loaded, load it and return it, end. Then, in another call: object asked id #1, it is already loaded, ret

[PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object

2005-05-10 Thread Lukas Smith
Leonardo Pedretti wrote: Yes, the question was pointed in another way, the destructors are not called until the last reference to an object has been removed, but if you store a reference in an array so you lately return a reference to the already loaded instance instead of creating an aliasing o

[PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object

2005-05-10 Thread Leonardo Pedretti
Yes, the question was pointed in another way, the destructors are not called until the last reference to an object has been removed, but if you store a reference in an array so you lately return a reference to the already loaded instance instead of creating an aliasing of that instance, then you

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Ondrej IvaniÄ
Lukas Smith wrote: > So please explain to me how you would write a singleton static method > for a base class from which you can inherite. Suddenly the idea with > using the class name becomes less useful. IMHO, you need singleton factory :) Inheritance is very strong relationship between classes

[PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object

2005-05-10 Thread Lukas Smith
Leonardo Pedretti wrote: It would not be such a problem to write something that does the same task through a static or global function, but unfortunately it is impossible, due to the following: you can build a cache in an array, then in a __new() function you could check if the requested object

[PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object

2005-05-10 Thread Leonardo Pedretti
It would not be such a problem to write something that does the same task through a static or global function, but unfortunately it is impossible, due to the following: you can build a cache in an array, then in a __new() function you could check if the requested object is already loaded and ret

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Lukas Smith
Lukas Smith wrote: Sebastian Bergmann wrote: Lukas Smith wrote: http://bugs.php.net/bug.php?id=30235 I agree with Marcus: self is bound at runtime, so the behaviour is correct. If you do not like this late binding just do not use self but the name of the class. So please explain to me how you

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Lukas Smith
Sebastian Bergmann wrote: Lukas Smith wrote: http://bugs.php.net/bug.php?id=30235 I agree with Marcus: self is bound at runtime, so the behaviour is correct. If you do not like this late binding just do not use self but the name of the class. So please explain to me how you would write a single

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Markus Fischer
Jason Sweat wrote: When the class is named SomeLongNameBecauseWedontHaveNamespaces and I define a SELF_EXPLAINING_CONSTANT_NUMBER_ONE I've to write SomeLongNameBecauseWedontHaveNamespaces::SELF_EXPLAINING_CONSTANT_NUMBER_ONE to access it from within the class itself. Is there a way to reference con

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Jason Sweat
On 5/10/05, Markus Fischer <[EMAIL PROTECTED]> wrote: > When the class is named SomeLongNameBecauseWedontHaveNamespaces and I > define a SELF_EXPLAINING_CONSTANT_NUMBER_ONE I've to write > SomeLongNameBecauseWedontHaveNamespaces::SELF_EXPLAINING_CONSTANT_NUMBER_ONE > to access it from within the cl

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Marcus Boerger
Hello Markus, Tuesday, May 10, 2005, 8:31:05 AM, you wrote: > Sebastian Bergmann wrote: >> Lukas Smith wrote: >> >>>http://bugs.php.net/bug.php?id=30235 >> >> >> I agree with Marcus: self is bound at runtime, so the behaviour is >> correct. If you do not like this late binding just do not us

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Markus Fischer
Marcus Boerger wrote: I agree with Marcus: self is bound at runtime, so the behaviour is correct. If you do not like this late binding just do not use self but the name of the class. Sorry to jump in the middle, but I've similiar question to constants defined in classes. When the class is named

Re: [PHP-DEV] Binary data in session

2005-05-10 Thread Petar Nedyalkov
On Tuesday 10 May 2005 00:48, john wrote: > I have been developing a site which stores an image files binary data > inside a session variable. Initially, I was developing this site on the > following environment: > > Apache-2.0.52/PHP5.0.3/Windows XP > > Things worked very well, as I expected them

Re: [PHP-DEV] Re: new overloading feature?

2005-05-10 Thread Markus Fischer
Sebastian Bergmann wrote: Lukas Smith wrote: http://bugs.php.net/bug.php?id=30235 I agree with Marcus: self is bound at runtime, so the behaviour is correct. If you do not like this late binding just do not use self but the name of the class. Sorry to jump in the middle, but I've similiar quest