Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18329 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5699 invoked by uid 1010); 24 Aug 2005 00:05:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 5684 invoked from network); 24 Aug 2005 00:05:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Aug 2005 00:05:15 -0000 X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6 Received: from ([69.12.155.130:4878] helo=pigeon.alphaweb.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 39/B7-28235-AB9BB034 for ; Tue, 23 Aug 2005 20:05:15 -0400 Received: from localhost ([127.0.0.1] helo=peiscg33m) by pigeon.alphaweb.net with smtp (Exim 4.10) id 1E7i8Y-0006GV-00; Tue, 23 Aug 2005 16:24:58 -0700 Message-ID: <010901c5a83f$7eb7ade0$5c8be5a9@ohr.berkeley.edu> Reply-To: "Sara Golemon" To: "Andi Gutmans" Cc: References: <004501c5a813$1691dc30$5c8be5a9@ohr.berkeley.edu> <6.2.3.4.2.20050823161755.03bffe20@localhost> Date: Tue, 23 Aug 2005 17:05:04 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 Subject: Re: [PHP-DEV] Returning References from Internal Functions From: pollita@php.net ("Sara Golemon") > We'll take a look at it as this should actually work today. > That's what I'd thought coming into this, but all my attempts to return a reference failed: My Arg Info struct: static ZEND_BEGIN_ARG_INFO_EX(php_sample_retref_arginfo, 0, 1, 0) ZEND_END_ARG_INFO() My reference linking: if (return_value_ptr) { zval_ptr_dtor(return_value_ptr); } SEPARATE_ZVAL_TO_MAKE_IS_REF(&val); ZVAL_ADDREF(val); *return_value_ptr = val; There's some commented out code in there that refers to bug 34045: /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) if (!EX(function_state).function->common.return_reference) { EX_T(opline->result.u.var).var.ptr->is_ref = 0; EX_T(opline->result.u.var).var.ptr->refcount = 1; } */ With that code in there returning references would certainly never work so I'd be curious about the events leading up to that removal as much as anything. > As to back porting, I don't think we should touch the stable branches. > Eh, it's a 50/50 on this one since the bug only effects internals code and (last I checked) there's nothing internal that's trying to return a reference other that OOP code (because it gets shoved into being a reference anyway). I only came across this because I was trying to come up with some example code "If you wanted to do this you could...". I know I personally would like to see it work in 5.1 at the least (being shy of final such as we are...). As for 5.0... yeah let's sleeping dogs lie. -Sara