Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23003 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49005 invoked by uid 1010); 28 Apr 2006 01:35:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 48990 invoked from network); 28 Apr 2006 01:35:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2006 01:35:37 -0000 X-PHP-List-Original-Sender: penguin@php.net X-Host-Fingerprint: 213.237.67.135 213.237.67.135.adsl.by.worldonline.dk Linux 2.4/2.6 Received: from ([213.237.67.135:29990] helo=mail.ter.dk) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id F1/5D-11022-86171544 for ; Thu, 27 Apr 2006 21:35:36 -0400 Received: from workpenguin (workpenguin [192.168.1.32]) by mail.ter.dk (Kaffemaskine) with SMTP id BD6A88A40D1 for ; Fri, 28 Apr 2006 03:35:39 +0200 (CEST) To: internals@lists.php.net Date: Fri, 28 Apr 2006 03:35:25 +0200 Message-ID: References: <444FF5CD.2010805@dealnews.com> <444FF716.6070201@lerdorf.com> <44512305.90207@pobox.com> <445136A7.3000801@lerdorf.com> In-Reply-To: <445136A7.3000801@lerdorf.com> X-Mailer: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Passing functions to function by reference From: penguin@php.net (Peter Brodersen) On Thu, 27 Apr 2006 17:24:55 -0400, in php.internals rasmus@lerdorf.com (Rasmus Lerdorf) wrote: >It also tends to be a bug. Most functions that take an argument by=20 >reference do so for a reason. There are of course exceptions to this as= =20 >you have pointed out and in those cases assuming your code will never=20 >run under PHP 4.3.x it can be valid. I would still say it is a better=20 >idea to something like: > > func_taking_reference($quiet=3Dsome_func()); // throw away ref mod > >and document the fact that you are intentionally throwing away the=20 >reference modification that func_taking_reference is making. That way=20 >you avoid the E_STRICT and make it very clear what you are doing. It seems like a lot of these problems showed up because people used array_shift(), array_pop() or other such functions as a shortcut of retrieving an element returned from a function. I agree with the changes, but it still seems like people (mis)use these functions because of lack of array operators (e.g. array(2,4,3)[1] ). I don't know if I would go that far to state that there is a demand for such operators (and the discussion has been going on here before). But if there is no (just as) simple way of doing it right users will do it in a bad way. --=20 - Peter Brodersen