make new return a reference to existent object

php.internals

Leonardo Pedretti

21 years ago
I would like (for code cleanliness purposes) to make 'new' return a reference to an already created object under certain circumstances without using a factory, is it possible? Thanx
-- Leonardo Pedretti Axon Sistemas Líder de Equipo Proyecto Basalto

Jason Barnett

21 years ago
Leonardo Pedretti wrote:
> I would like (for code cleanliness purposes) to make 'new' return a reference > to an already created object under certain circumstances without using a > factory, is it possible? > > Thanx
"Under certain circumatances" ? ... If it's only under certain circumstances that you want a reference versus a copy versus an actual new object... well then why not use factory methods? Or perhaps you meant something like a "Singleton": http://phppatterns.com/index.php/article/articleview/6/1/1/

Sara Golemon

21 years ago
> I would like (for code cleanliness purposes) to make 'new' > return a reference to an already created object under certain > circumstances without using a factory, is it possible? >
* Sara whispers "old" into the conversation and runs away

Jason Sweat

21 years ago
On 5/9/05, Sara Golemon <pollita@php.net> wrote:
> > I would like (for code cleanliness purposes) to make 'new' > > return a reference to an already created object under certain > > circumstances without using a factory, is it possible? > > > * Sara whispers "old" into the conversation and runs away
It's not "old", it is an experienced object ;) Regards, Jason http://blog.casey-sweat.us/

Jason Garber

21 years ago
Hello, -1 New implies "new". Use a factory. Maybe we should add an old construct: $object = old MyClass(); Just kidding :)
-- Best regards, Jason mailto:jason@ionzoft.com Monday, May 9, 2005, 10:30:56 AM, you wrote: LP> I would like (for code cleanliness purposes) to make 'new' return a reference LP> to an already created object under certain circumstances without using a LP> factory, is it possible? LP> Thanx