[PHP-DEV] Constant Classes

2002-04-14 Thread medvitz
This may have been addressed already but: If I have the following code: class Beer { ... } $a = new Beer(); define('BaseBeer', $a); $b = BaseBeer; Will $a & $b be the same object or will $b be a copy. (Under ZE2). Thx. Medvitz -- PHP Development Mailing List

Re: [PHP-DEV] Constant Classes

2002-04-14 Thread fabwash
Definitely a copy if you're drunk after all those beers.. (sorry couldn't resist) Fab. - Original Message - From: "medvitz" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, April 14, 2002 10:33 AM Subject: [PHP-DEV] Constant Classes >

Re: [PHP-DEV] Constant Classes

2002-04-14 Thread Zeev Suraski
It'll be the same object. At 17:33 14/04/2002, medvitz wrote: >This may have been addressed already but: > >If I have the following code: > >class Beer >{ >... >} > >$a = new Beer(); > >define('BaseBeer', $a); > >$b = BaseBeer; > > >Will $a & $b be the same object or will $b be a copy. (Un

Re: [PHP-DEV] Constant Classes

2002-04-14 Thread medvitz
Should it be the same object, though??? I thought that the whole concept of a 'constant' was that it, well, was constant. Wouldn't it make more sense to auto-clone objects when they are accessed through a constant Medvitz Zeev Suraski wrote: > It'll be the same object. > > At 17:33 1

Re: [PHP-DEV] Constant Classes

2002-04-15 Thread Stig S. Bakken
Assigning an object to a constant is, IMHO, abuse of constants. What would you expect? An immutable object? You would probably be better off making a function to clone your object or something like that. - Stig On Mon, 2002-04-15 at 02:52, medvitz wrote: > > Should it be the same object, th

Re: [PHP-DEV] Constant Classes

2002-04-15 Thread Zeev Suraski
No, if you use the reference logic, than the fact that BaseBeer is defined to be a certain reference, is the meaning of it being constant. The contents of the object this reference points to may change. You just have to get used to the reference based logic. That said, it doesn't make too mu

Re: [PHP-DEV] Constant Classes

2002-04-15 Thread Medvitz
What I was hoping for is that when it was defined, that the value stored would be a copy of the object at that point in time, and that whenever you set a var to that constant you would get a new copy of what was defined. I guess, then, I can set a variable to a reference of a constant too

Re: [PHP-DEV] Constant Classes

2002-04-15 Thread brad lafountain
what about.. class Beer { ... } $a = new Beer(); define('BaseBeer', $a->__clone()); $b = BaseBeer; or class Beer { ... } $a = new Beer(); define('BaseBeer', $a); $b = BaseBeer->__clone(); - Brad --- Medvitz <[EMAIL PROTECTED]> wrote: > > What I was hoping for is that when it