Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103109 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9790 invoked from network); 31 Aug 2018 22:55:19 -0000 Received: from unknown (HELO mail-wr1-f50.google.com) (209.85.221.50) by pb1.pair.com with SMTP; 31 Aug 2018 22:55:19 -0000 Received: by mail-wr1-f50.google.com with SMTP id u12-v6so12083311wrr.4 for ; Fri, 31 Aug 2018 11:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BKLZBD03BZWGz2G95zmvamxipGjCR/KqgQQ5pKm/Ds8=; b=g+LVNFnOtOMhWgMzDX4e7m+lrtw8+uHoeUegTs+My5kI0qn2xWbeyvivdPZVNYF33e YXt1RPMUzd8oNz2iE+mzG0KWEqFgLcIvCgEKXym4L7ZRGiyhnPTnmQqrixYjGYOBBiDj jw3iOK6A71zOZAHM0Oj6xd0HP6JeRL84YRDPoXujazF9/QEMqWArlkDdZHuy6bDzszq7 jAEKkfAZPSrPsWBaqSdWU67dsbd2oTMWeAKsecUKCkbkV+QhIg0YuTFsg6mU7PT9iEdc tlN12uG1Lt42GvO+L6ZWGT+7LQKJaId5sZi7WQTAuvwiRuDzrG/sI1ulAxYfmps5no0N t9Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BKLZBD03BZWGz2G95zmvamxipGjCR/KqgQQ5pKm/Ds8=; b=sfp9circduNvSGwWoMLaz+oeZCjn63NBIrW4l/sGUp+agbTEw4zR1kh5o26RhrWpEw D+jWT2YnwGNuI9Ra9wqkoKAzSRNkGcv/tEXihiSAS5prKKYg46ENqX4m6iCXyq9viiP5 n/OQ4tF6Up29gxB/mIyYvZRbe5FAJnea95EWceOUNPKuKmWCrV6b1pMmhEx4+8aT1L7A hBbfPBkzUpF2P9syZi5EG7KWZ2WPot2xEzom9waAgEoF4gPCtJW2Wmfjb+d97qoB00Xz lyn1/iufm24SZujMoXqsicjTHMUJ1vUqQ13sg4y4WE/3JucFHOBlJdddh27L31IUbIcK 60GQ== X-Gm-Message-State: APzg51D6nFH2eu5Y6ntR/QnHWao+CfREjvM7dtbkhxDVatA/FZ1lDUcr QIH6V41rk9QzDOoyTUxDEDvbR79WXyGdz8bSxgs= X-Google-Smtp-Source: ANB0VdZvFa54xcCmPeMBJE3JfmrdbxS69oJ1fMxPplRymypQJv7IRx5zhP7dpioS7jdC5dodjIrBPEYpn1LooNTA9Mg= X-Received: by 2002:adf:94a6:: with SMTP id 35-v6mr11479663wrr.54.1535741819324; Fri, 31 Aug 2018 11:56:59 -0700 (PDT) MIME-Version: 1.0 References: <93906607-BDF3-4021-95F0-AFBA87AB5F6B@gmail.com> In-Reply-To: <93906607-BDF3-4021-95F0-AFBA87AB5F6B@gmail.com> Date: Fri, 31 Aug 2018 20:56:46 +0200 Message-ID: To: Claude Pache Cc: PHP Internals List Content-Type: multipart/alternative; boundary="0000000000009b8f230574bfc12f" Subject: Re: [PHP-DEV] Assigning to a reference returned by a function/method From: ocramius@gmail.com (Marco Pivetta) --0000000000009b8f230574bfc12f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'd rather put everything that has to do with references in a pot and throw it at the core of the sun =F0=9F=94=A5 Expanding features around references, especially since they are known to be problematic, makes them a bigger problem. On Fri, 31 Aug 2018, 20:44 Claude Pache, wrote: > Hi internals, > > > Today I tried something like that: > > function &fooRef(...$args) { > // ... impl details > return $someRef; > } > > fooRef('a', 'b') =3D 42; > ?> > > and it failed miserably (Fatal Error: Can't use function return value in > write context). > > Naturally, as workaround, I could write: > > $ref =3D& fooRef('a', 'b'); > $ref =3D 42; > unset($ref); > ?> > > which is passable for one instruction, but not so much for ten similar > instructions in a row. > > Another hackier workaround: > > function arrayFoo(...$args) { > // ... impl details > $arr =3D [ &$someRef ]; > return $arr; > } > > arrayFoo('a', 'b')[0] =3D 42; > ?> > > (... and I was wondering that it worked, while ][0] =3D 42; ?> triggered a fatal error). > > > So... what do you think? Is it reasonable to allow to assign to a > function/method return value, when it is a reference? > > > =E2=80=94Claude > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0000000000009b8f230574bfc12f--