RE: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy
| From: | Heinz Doerr | Date: | Thu, 17 Aug 2000 18:28:52 +0000 |
| Subject: | RE: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-29318@lists.php.net to get a copy of this message | ||
Waldschrott,
I completely agree to your statement below.
Plus, it's trist.
One single change and many problems in PHP oo behaviour would disapeare.
The change:
1.) The new constructor always returns references or alternatelly
we would need a syntax like &new
2.) The assignment operator handles references as references not
as the value of the reference.
The benefit:
1) The constructor works as any other member function!
2) The performance of an object constructor get's MUCH faster.
From my e-mail discussion yesterday with Stanislav, I understood:
$myinstance= new MyClass(...);
This simple instruction generates from my understand 2 or 3
shallow copies in the background before it finishes!!!!!!!
3) That's may be most important:
PHP would have no problems with circular references anymore.
I have tested it - PHP can handle circular references w/o problems.
Surely enough - as with any other language e.g. Java, C++, Perl -
the programmer of circular referenced data structure must carefully
clean the structure (destruct).
4) My definition of a bug in short form is 'unexpected behaviour'.
And I make any bet, that most - maybe almost anyone - doesn't
expect the current behaviour.
e.g. I can't understand that a language push me to declare return
by reference twice:
function &member(..) { ... };
$x= $member(..);
THAT IS CRAZY - sorry.
5) I guess that the construct $obj1(..)->member1(..)->member2(..)
could than easily be supported.
Today I need to write: $obj2= &$obj1->member1(); $obj2->member2();
I believe, that this not working statement in PHP show's that
there is something broken internally! (This is bug #4 = buy the way!
6) Shallow copies can be avoided - I have not yet found any computer science
specialist you call's shallow copies a good language construct!!!!
If you don't make this change fast - you may not be able to change it
anymore. Or many existing program's will break!!!!
But as as of today, you have just started to introduce the return
by reference functionality.
Let me just say - beside this object-by-value behaviour I really like
PHP - it's a creat server side scripting language.
Greetings
Heinz
-----Original Message-----
From: Bug Database [mailto:php-dev@lists.php.net]
Sent: Donnerstag, 17. August 2000 14:46
To: Heinz@chanet.de
Subject: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy
ID: 6193
Updated by: waldschrott
Reported By: Heinz@chanet.de
Status: Analyzed
Bug Type: Feature/Change Request
Assigned To:
Comments:
urgs, that´s a pity - there´s some unexpected behaviour
using references, we should document this unless it´s not
improved...
Full Bug description available at: http://bugs.php.net/?id=6193