Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114675 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40711 invoked from network); 31 May 2021 09:49:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 May 2021 09:49:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AD3621804CC for ; Mon, 31 May 2021 03:02:40 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 31 May 2021 03:02:40 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id w33so16010211lfu.7 for ; Mon, 31 May 2021 03:02:40 -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=eSuvPj6qbTGPBNKvYQeI/DlThiEcc1brI8QV/A7M/j8=; b=PF7vMdm3xw1qZ2TzabvHnK5CVLihaWcTc07FsnVz0SzQkaK795Qky93bsOeNZPWYwF E+8y8KvUCECpfnWsLqY4aA4QWpGmXtYV/HFODtiwRvrVvIln1G1/HQRczCGbbE21QRA7 Bll5A6UrOymuzxJqWYAua2AXpDR8Kg8bx7bmiWvibeAbVh5KVQZaFZcfG8/kz1QbZkqA 44XksenCWVyk24+V0XHuPTVc8UeVpmmNYVuVl6qrsGe1+kL6JjSx0G2IAsH8zXm2JODw Lbo3hGYYsq9ECpG3s28u29fJwaGAdfl6jjVzEDlD07WKPg5okff/wnX1Ilk3oaJD9xbj h2RQ== 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=eSuvPj6qbTGPBNKvYQeI/DlThiEcc1brI8QV/A7M/j8=; b=Q7Ve3ohLMEPY2yVz1GPw5r5UNjhWeqIQlFAaXMiYow2VFu5BH5PaiuoO55Hv6RxbLD R+H65y5wP9k0oWnWU9ZIzqJRLVtQIsv81AbxkYR1qqsqW0jkt8+lLFr4tg2MuDqgZ4q3 dF5jDtbEYv7VGjduDpIdp77OtFUvg6i1cyG7uxTFAxFMiTYJGfsVk6eYKI2x3ud5sR6+ Tns1AivAZFyY7nHN0FGvQzGF5NXIlNPEBQ4EgsvNJIwPRyEohiQqMYC4xLsAm6b84O3g AAAAcuA2SxzijurQeH+Sf6DzxcSjwV6CcFtkSGjkEPukZDoVkTV/1GWdS7rKPFUHSp+5 MDFQ== X-Gm-Message-State: AOAM531AArSGVms6+iw0eC5yZKatUZFUaCYQHv7vr2FIHwOcQz0MlM8w L+4S7Dzpd7Z4683UpfZQy3RWvXrJ4ZZQ3N5J0fks/rZX8Lc= X-Google-Smtp-Source: ABdhPJz7CArjd0ZSo9G0nqtaAs4cF6hP4JrwYd8XFGiaxAil0s/VMFuWf1F8ltNxXFuWQLxQjNEAl8pDbGBRXUL7WC0= X-Received: by 2002:a05:6512:20ca:: with SMTP id u10mr14114770lfr.315.1622455357620; Mon, 31 May 2021 03:02:37 -0700 (PDT) MIME-Version: 1.0 References: <60b13dc9.1c69fb81.39116.72e0SMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <60b13dc9.1c69fb81.39116.72e0SMTPIN_ADDED_MISSING@mx.google.com> Date: Mon, 31 May 2021 12:02:21 +0200 Message-ID: To: Mark Randall Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000004147f905c39d53d4" Subject: Re: [PHP-DEV] A little syntactic sugar on array_* function calls? From: nikita.ppv@gmail.com (Nikita Popov) --0000000000004147f905c39d53d4 Content-Type: text/plain; charset="UTF-8" On Fri, May 28, 2021 at 9:00 PM Mark Randall wrote: > On 28/05/2021 15:31, Nikita Popov wrote: > > This is a more complex case. In this case the compiler doesn't know in > > advance whether the argument is passed by value or by reference. What > > happens here is: > > > I'm trying to wrap my head around this, but if a function arg can handle > this, does something internal to the engine preclude fetching in write > context, after already fetching in read context, other than performance? > > So can the initial fetch be performed with FETCH_DIM_R, handling the > object case + any other scalars, and if and only if the value is an > array and operating on what would traditionally be a by-ref, repeating > the previous lookup with FETCH_DIM_W? > This is theoretically possible, in that this is exactly how $a[$b][$c] ??= $d is implemented. Everything is first fetched as FETCH_DIM_IS and then again as FETCH_DIM_W if an assignment is necessary. However, this does require emitting both fetch sequences, with one guarded by a branch, together with temporary copies to allow re-fetching without re-evaluating side-effecting operands. Of course, it also has fun interactions with magic ArrayAccess/__get, in which case both fetches may produce different results. All this is something we can live with for the ??= operator, but not for every single method call. Regards, Nikita --0000000000004147f905c39d53d4--