Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105324 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23028 invoked from network); 21 Apr 2019 22:36:24 -0000 Received: from unknown (HELO mail-pl1-f196.google.com) (209.85.214.196) by pb1.pair.com with SMTP; 21 Apr 2019 22:36:24 -0000 Received: by mail-pl1-f196.google.com with SMTP id d1so4820831plj.8 for ; Sun, 21 Apr 2019 12:36:22 -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=douM+11ZbD+a1pLKRFSk5sFGvvgKsrv1WoQgQu6nXdE=; b=uMrpsWxzTGWdEJnlMTHNEOopVtoaVEIoXrUQIwttWpFUh7EDD0fr4kKxIxSgGfSc2D LN47A5ezKswy610MH44AGjN3huwYzZXjWKO+AoYaxUAYsC/aWihF9H/g+GyZKrL362xW yPVRjtYmzy4dU/w4oUtBlbaPgCxCpum28wdCP/zDMPwGfFbEhaJ0MqJKCr99kLN4Ixdd YIgZJ7IGbwPy8ld7bLs6Eki4+XHjyUYqPXqoZH5CXIPYRk2HSfLEvd8YUnxnC2t8AE/g fgidmrwKFEflFcCd7oZDkwQDRqXs35/SyKpRZtcZaX5EJMUBrkmIjliONtdx2MDjEqni A3JA== 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=douM+11ZbD+a1pLKRFSk5sFGvvgKsrv1WoQgQu6nXdE=; b=g4lSCbybWYjT6M0wqgGx66+ZwPG88MQ0U4nMTHtAbnSM+o4NjW0TjTZXZ3UpDYRXx+ Phc1v8B1TFPphZQ2/TgFGNQrqsh6LW7PGTEfYGMZJdIjAriIhqLGeZWhleB4j7NhFpgL notcrbyw0eh6hcmfexUxFJRMzAl2LQfLeCFLF0bxzLyUu7Y0OjS8oLrijq4ITMe9l8aR bhSWjwaHxSJBmAqUmp9ZrrKvGAZrp2696a23noCmukRrHVAReur6FuLWvVrSbdoAOxP1 LigART6mDdmgv6rarn2gwciJAWP6LliuLilhmHhW5t8GY7kx0DpuWWb2ZmvWkbyE+3Hf Vm9Q== X-Gm-Message-State: APjAAAXMPhSvYHwwCToo7zhXU87Z75/LaGMq9y7XdvBHOpR5nXgYU4fY +kbJVR2jY93+h1uByxgIEZNvnsTV/VzWVCwc6h0= X-Google-Smtp-Source: APXvYqyNiiIOfsXVCRsbVYSr1IuQooLa4e8fY7BaXh1x6fyjYnVHUKjTHUEEVBCPY5pfPAKEYnribMVW6FV5iTGSIsc= X-Received: by 2002:a17:902:1602:: with SMTP id g2mr16177656plg.325.1555875381477; Sun, 21 Apr 2019 12:36:21 -0700 (PDT) MIME-Version: 1.0 References: <003a01d4eaf0$c17d6c20$44784460$@jhdxr.com> <000301d4f878$cbdbf160$6393d420$@jhdxr.com> In-Reply-To: <000301d4f878$cbdbf160$6393d420$@jhdxr.com> Date: Sun, 21 Apr 2019 12:36:32 -0700 Message-ID: To: CHU Zhaowei Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary="0000000000006d846f05870f77f9" Subject: Re: [PHP-DEV] [RFC] Spread Operator in Array Expression v0.2 From: mo.mu.wss@gmail.com ("M. W. Moe") --0000000000006d846f05870f77f9 Content-Type: text/plain; charset="UTF-8" Hello, "Since we can define array element by reference now, it doesn't make sense to change the way of storing values just because it's unpacking. In other words, the conversion of how values are stored isn't part of spread operator." yes it is; no matter what you "think"; banding reality/facts only exists in blockbusters. On Sun, Apr 21, 2019 at 12:31 PM CHU Zhaowei wrote: > On Monday, April 8, 2019 9:22 PM Nikita Popov > wrote: > > > This looks reasonable to me. My only concern would be the "by-reference > passing" section of the RFC. The current proposal states that [...$arr] > will preserve references in $arr, which is not the behavior I would expect. > > > > Is this choice for parity with the unpacking functionality in calls? In > that case I think it is important to understand that for argument unpacking > the handling of references is decided by the called function, not what is > in the array. If the function accepts an argument by-reference, then the > corresponding element in the array will be turned into a reference > (regardless of whether it was one before). Conversely, if the function > accepts an argument by-value, then the element from the array will be > passed by-value (regardless of whether it was a reference before). A > similar concept doesn't really exist for unpacking in arrays. > > No. I understand it's decided by the definition of the function that > whether the arguments are passed by-value or by-reference, and it's not > able to be changed by the caller. So the spread operator here extracts the > array, no matter it contains referenced element or not, and the conversion > from by-ref to by-val or by-val to by-ref is done during passing to the > callee. Back to the array definition scenario, the spread operator will > also extracts the array, and it should be the array definition to decide > whether conversion is needed. Since we can define array element by > reference now, it doesn't make sense to change the way of storing values > just because it's unpacking. In other words, the conversion of how values > are stored isn't part of spread operator. > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0000000000006d846f05870f77f9--