note 50007 added to language.oop.newref

From: Date: Tue, 15 Feb 2005 07:48:45 +0000
Subject: note 50007 added to language.oop.newref
Groups: php.notes 
Request: Send a blank email to php-notes+get-85052@lists.php.net to get a copy of this message
As your can see your ploy to fix the ills of programming hackery just failed.. What are you going to do to encourage better coding practices? Change syntax and semantics until things look nice? I use PHP because it doesn't look like Perl, but if I want clean code, I'll program in python.. This is a bogus reason to deprecate something.. I say you revert back.. BTW, Pear is okay but I can see bigger holes in PHP like the lack of a configurable VM, this is why Python is potentially better when it comes to OO and CMS's .. PHP just lacks better abstraction.. But its good for hacking pages together, which is where its strangth is.. People like it because there is no guesswork when you want something to work.. This is why I think Zend and Sun are going to ultimately fail.. Sun deprecates libraries and classes by the whims of the CEO, that's why Java sucks for web development, inconsistency across classes.. Its not a problem Smalltalk had, its a problem that comes from treating an interpretive language like its a compiled language.. Java is just as much and octopuss nailing tentacles on as C++ is.. If it was trully cross platform compatible, Sun would have not deprecated anything, and just spawned versions, like a log-system or a CVS.. Of course, Java is a commercially developed language, with some open source counterparts, since its privately owned, developed and controlled, what makes you think it will remain consistent for logical reasons.. And furthermore why do you think PHP will? ---------------- Ah HA! I just found an easy workaround with a bit of playing. This works: --- cut --- $OBJECTS = array(); class Object { function &Object() { global $OBJECTS; $OBJECTS[] = &$this; } function _init() { } } class Derived { function &Derived() { Object::Object(); } } function blah() { global $FOO; $x =& new Derived; $GLOBALS['FOO'] = &$x; $x->foo = 42; display("x", $x); } function display($text, &$o) { echo("($text) =>" . serialize($o)); } blah(); display("GLOBALS[FOO]", $GLOBALS['FOO']); display("OBJECTS", $OBJECTS); --- cut --- As you can see, simply adding & before the constructor to make it return a reference does the trick. The bit about "returning a copy by default" lead me to try this trick, and it seems to work. Have fun! -rjp ---- Manual Page -- http://www.php.net/manual/en/language.oop.newref.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50007 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50007&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50007&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50007&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50007&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50007&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50007&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85052) next »