Hi, Let me declare open season for references. As they make it impossible to use call_user_func_array and other cute tricks are also impossible, they are a hinderance. I fail to see the benefit for us. Let's get rid of all. Who wants to join me on the hunt? Regards NK
Regarding Let me declare open season for references. As they make it impossible to use call_user_func_array and other cute tricks are also impossible, they are a hinderance. I fail to see the benefit for us. Let's get rid of all. Who wants to join me on the hunt? References have a place in programming and do help with performance when dealing with large objects or arrays. For example node_submit is called with a reference to the node, so it can directly make changes to the values. If you removed the reference a copy would be passed in and the hook would need to return a copy. So you would go from passing a reference to copying the node twice. So personally I think the performance aspect is more important that the ability to do 'cute tricks'. Steve Ringwood
References have a place in programming and do help with performance when dealing with large objects or arrays.
Wrong on arrays. http://web.archive.org/web/20060427154547/http://www.zend.com/zend/art/ref-c... Objects in PHP4 yes but while we want Drupal working still on PHP4, it's not a preference or priority any more at least for me. So if there is a minuscule performance penalty 'cos ancient PHP versions copy around objects so be it. As said, if I find the need for more advanced array function, I will use them and reimplement them for PHP4.
On Tue, 06 Mar 2007 19:15:40 +0100 (CET), "Karoly Negyesi" <karoly@negyesi.net> wrote:
References have a place in programming and do help with performance when dealing with large objects or arrays.
Wrong on arrays.
http://web.archive.org/web/20060427154547/http://www.zend.com/zend/art/ref-c...
Objects in PHP4 yes but while we want Drupal working still on PHP4, it's not a preference or priority any more at least for me. So if there is a minuscule performance penalty 'cos ancient PHP versions copy around objects so be it. As said, if I find the need for more advanced array function, I will use them and reimplement them for PHP4.
And actually PHP does copy-on-write, so if you pass a 5 MB object to a function "by value" but then do not modify it, you are only using 5 MB, not 10 MB of RAM. As soon as you modify it, PHP pauses, copies the actual data in RAM (using up 10 MB total now), then modifies the copy then. There is actually slight more internal overhead for an explicit pass by reference than for a pass by value. Of course in PHP 5, Objects are now "super resources" rather than "super arrays", so from a data-modification perspective they become effectively by reference anyway. There are also ways to get an object through call_user_func_array() by reference in PHP 4. They're annoying, but they work. As killes said, right tool for the job at the time. --Larry Garfield
Karoly Negyesi wrote:
Hi,
Let me declare open season for references. As they make it impossible to use call_user_func_array and other cute tricks are also impossible, they are a hinderance. I fail to see the benefit for us. Let's get rid of all.
Who wants to join me on the hunt?
No, I'm against this. Having to return objects all the time can be problematic. Sometimes references are the only reasonable way to do these things. I realize they don't work well with func_get_args, which is unfortunate, but that's not a good reason to stop using references, IMO.
Karoly Negyesi wrote:
Hi,
Let me declare open season for references. As they make it impossible to use call_user_func_array and other cute tricks are also impossible, they are a hinderance. I fail to see the benefit for us. Let's get rid of all.
I am a big fan of "the right tool for the job". If a reference is the right tool, then let's use it. If it isn't it can be removed of course. Cheers, Gerhard
participants (5)
-
Earl Miles -
Gerhard Killesreiter -
Karoly Negyesi -
Larry Garfield -
Steve Ringwood