Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124516 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 472AC1A00B7 for ; Sat, 20 Jul 2024 15:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721490282; bh=HmloVp3Z6LZdZ4h2lk1Z9rbEzXGVpi17EWapWKnOD0M=; h=Subject:To:References:From:Date:In-Reply-To:From; b=DcI6Tf00dCW3egVJb2bfasw4V1h9lB7H01MeeWil+lVT2QBsRCd5Ss0TUP9enuxpI 8KCdROlxgNi+S75sjwae1pzSiG5TJRuYdr7jPbssrQcfTG3MhaZrdgl/O4dTam8xu5 W9yHJogggf4S7bPWIO1uOZp0ArdiTMvmjBH5BIxKzqatGP+ayl63ltwHKv+HjZQ7Mv +aKuVONcQsjXYmB7l6zLY8GVo9yCcsg9OgbNdN8PxrYR4tH7lyFWHgaTlLYYZLIyRD cfVw077sWee6rbKYmt5u9KUAQQPoeUis8DwC9YpMtBUgDDJsgdagSpede2+W0Jigbb tOBpElaMcizjw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D6103180087 for ; Sat, 20 Jul 2024 15:44:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: ** X-Spam-Status: No, score=2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from dormouse.elm.relay.mailchannels.net (dormouse.elm.relay.mailchannels.net [23.83.212.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 20 Jul 2024 15:44:40 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 264A3C5DEE for ; Sat, 20 Jul 2024 15:43:08 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id A668BC4DE4 for ; Sat, 20 Jul 2024 15:43:06 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1721490187; a=rsa-sha256; cv=none; b=eULUnr26EQam4RsYqSZ9oSZK4uAdw1beGoXUO+AsET/xmJvwfAiQ/CF4P0CBdERsWy9zFO H5CwhoX836voLQ9R0yJ0Lta1CmjqroX+jSPUV36Sambbu+ir1gCGe47Stb8i3kofMc30FQ m0SRd3PICtyt3S9hPOLF64S8Eh6E+DZJAGb3kY2ophA4YGEFxEQkQ4tSbtL8PGeF4seuSp A3E9u4u8aDBrZo8XFoHD1Bbpn/5MBxrBSZgH9ryxPXSot+LHqceg0EZTytIMSlqfYQEyBb KMhXU7VSij+8HHxNelSI+Vl5VqeN83wfP5kEFEwXtCyOEPwh9E+Ftse3Z/TAKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1721490187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XRlSJGMgOB1RaP5sa3zllYJAVgurxyn4GAvijODz6ds=; b=t2H/gIGoBUH/8C4GACjhSotq0Wf6zXK6ahk/je25VZjfLsUOkX6KHb7Bh5Gigrr+j3RfrJ vJNX74xbyD2DKH1+D/OY9pAu90abf+tAZd+Hmkr3FImmnsGk5P2k7H+dU/jeLkH66ih37l EOWGcWFNAvGqsWUCC94XrIjpami0HAwN4Rhf+xbukKb1DAiCHHZlGMCk3JIhjct6XANHtg GtwuoQl4ZhWSIyfByjXRJj5MRCdSegGYNN48YsUZoTNwNcwX5OOZQSIzJWZ0s5Bm3u0Um6 FL6f+n9Pb4Q2t+VOaY/QBEcPk5evK/ccnfs4znCTN56u80uWR4brGFAHllS5BA== ARC-Authentication-Results: i=1; rspamd-5d9c874f6d-6ssp8; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Lonely-Interest: 0685e1670cca3ecb_1721490187200_3458072453 X-MC-Loop-Signature: 1721490187200:676830747 X-MC-Ingress-Time: 1721490187200 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.104.53.189 (trex/7.0.2); Sat, 20 Jul 2024 15:43:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XRlSJGMgOB1RaP5sa3zllYJAVgurxyn4GAvijODz6ds=; b=BapwW7h2dkYol4couo/mFt/kry QBXQg7nWMEvaaXT0uZpy9GBxti2O2Oalcg0oSW4RZMr5phGDdWKI60lkw8MJsSBoTP7vCTIym9emq q89EtVuvDHR4NeohjTG7IO08/gN+vYE43O6xFAefzJ4+eBwz7SrX3bZAOIBCEQI9fZ3o=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.97.1) (envelope-from ) id 1sVCEi-0000000EQoL-3oC3 for internals@lists.php.net; Sat, 20 Jul 2024 17:43:04 +0200 X-ImunifyEmail-Filter-Info: UkNWRF9WSUFfU01UUF9BVVRIIFJDVkRfVExTX0FMTCBWRVJJ TE9DS19 DQiBSQ1ZEX0NPVU5UX09ORSBCQVlFU19IQU0gQVJDX05BIE1JTUVfVU 5LTk9XTiBNSURfUkhTX01BVENIX0ZST00gSUVfVkxfUEJMX0FDQ09VT lRfMDUgTUlNRV9UUkFDRSBGUk9NX0hBU19ETiBUT19ETl9OT05FIFJD UFRfQ09VTlRfT05FIElFX1ZMX1BCTF9BQ0NPVU5UXzAxIFRPX01BVEN IX0VOVlJDUFRfQUxMIEZST01fRVFfRU5WRlJPTSBBU04= X-ImunifyEmail-Filter-Action: no action X-ImunifyEmail-Filter-Score: 0.33 X-ImunifyEmail-Filter-Version: 3.5.16/202407201230 Received: from [31.201.40.213] (port=50625 helo=[192.168.1.16]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.97.1) (envelope-from ) id 1sVCEm-0000000EQoA-3g5n for internals@lists.php.net; Sat, 20 Jul 2024 17:43:04 +0200 Subject: Re: [PHP-DEV] Request for opinions: bug vs feature - change intokenization of yield from To: internals@lists.php.net References: <66984FD0.5090805@adviesenzo.nl> <6699F817.8070806@adviesenzo.nl> <9571bb82-9873-4319-9bd1-0361748335be@bastelstu.be> Message-ID: <669BDB00.70507@adviesenzo.nl> Date: Sat, 20 Jul 2024 17:42:56 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 In-Reply-To: <9571bb82-9873-4319-9bd1-0361748335be@bastelstu.be> Content-Type: multipart/alternative; boundary="------------050008020602030606080801" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------050008020602030606080801 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 20-7-2024 16:51, Tim Düsterhus wrote: > Hi > > On 7/19/24 07:22, Juliette Reinders Folmer wrote: >> More than anything, I find it concerning that this change sets a >> precedent for tokens to include comments. >> >> Just as an example: what does this mean for the PHP 8.0 nullsafe object >> operator ? Should we now suddenly allow that to be written as `? >> /*comment*/ ->` ? >> Or what about a cast token ? Should that be allowed to be `(string /*for >> reasons*/)` ? > > The difference between `yield from` and `?->` is that the former looks > and feels like it would be two separate keywords, because of the > *required* whitespace between the `yield` and the `from`. The fact > that a `yield` keyword actually exists also contributes to that. `?->` > on the other hand looks and feels like a single operator, just like > `++`, `!==`, `<=>` and others. > > Except for `yield from` the rule where comments may be placed as far > as I can tell is "comments may appear where whitespace may appear", > which is easy enough to explain and understand. So it makes sense to > allow for comments between `yield` and `from`, but I agree that > ideally those would be emitted as separate tokens. Tim, "comments may appear where whitespace may appear" ? You'd think so, except it isn't true. I already mentioned cast tokens before. Whitespace is perfectly acceptable within the parentheses of these. Comments are not: https://3v4l.org/A6Sgj and https://3v4l.org/nE9H8 Now you may argue that cast tokens "feel like" a single operator, but that's subjective and there's even a sniff to enforce no spacing within cast parentheses as apparently people do pad them with spaces - and doing so is allowed in PHP. * _* Qualifier: spaces and tabs are allowed inside cast parentheses, but new lines are not..._ Along the same lines and I'm beginning to repeat myself, the PHP 8.0 RFC which changed the tokenization of namespaced names explicitly disallowed whitespace and comments _inside_ namespaced names tokenized as a single token, while in the previous, multi-token situation, whitespace and comments were allowed in namespaced names. So to get back to my original point, as of PHP 8.3 is the **only** token which allows for a comment to be tokenized as part of the token. There is no other token which allows that. Whitespace is one thing, comments is a different matter. And even the whitespace is an interesting one as I've seen bug reports in PHPCS about a sniff breaking on `yield from` with a new line and indentation between the keywords. PHP allows this, the sniff in question does not handle it correctly. So, what "feels" natural (whitespace-wise) to one person may not be the same for the next, but comments _within_ tokens is different thing and should in my opinion, not be allowed. Smile, Juliette --------------050008020602030606080801 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 20-7-2024 16:51, Tim Düsterhus wrote:
Hi

On 7/19/24 07:22, Juliette Reinders Folmer wrote:
More than anything, I find it concerning that this change sets a
precedent for tokens to include comments.

Just as an example: what does this mean for the PHP 8.0 nullsafe object
operator ? Should we now suddenly allow that to be written as `?
/*comment*/ ->` ?
Or what about a cast token ? Should that be allowed to be `(string /*for
reasons*/)` ?

The difference between `yield from` and `?->` is that the former looks and feels like it would be two separate keywords, because of the *required* whitespace between the `yield` and the `from`. The fact that a `yield` keyword actually exists also contributes to that. `?->` on the other hand looks and feels like a single operator, just like `++`, `!==`, `<=>` and others.

Except for `yield from` the rule where comments may be placed as far as I can tell is "comments may appear where whitespace may appear", which is easy enough to explain and understand. So it makes sense to allow for comments between `yield` and `from`, but I agree that ideally those would be emitted as separate tokens.

Tim,

"comments may appear where whitespace may appear" ?

You'd think so, except it isn't true.

I already mentioned cast tokens before. Whitespace is perfectly acceptable within the parentheses of these. Comments are not: https://3v4l.org/A6Sgj and https://3v4l.org/nE9H8

Now you may argue that cast tokens "feel like" a single operator, but that's subjective and there's even a sniff to enforce no spacing within cast parentheses as apparently people do pad them with spaces - and doing so is allowed in PHP. *
_* Qualifier: spaces and tabs are allowed inside cast parentheses, but new lines are not..._

Along the same lines and I'm beginning to repeat myself, the PHP 8.0 RFC which changed the tokenization of namespaced names explicitly disallowed whitespace and comments _inside_ namespaced names tokenized as a single token, while in the previous, multi-token situation, whitespace and comments were allowed in namespaced names.

So to get back to my original point, as of PHP 8.3 is the **only** token which allows for a comment to be tokenized as part of the token. There is no other token which allows that.

Whitespace is one thing, comments is a different matter. And even the whitespace is an interesting one as I've seen bug reports in PHPCS about a sniff breaking on `yield from` with a new line and indentation between the keywords. PHP allows this, the sniff in question does not handle it correctly.

So, what "feels" natural (whitespace-wise) to one person may not be the same for the next, but comments _within_ tokens is different thing and should in my opinion, not be allowed.

Smile,
Juliette





--------------050008020602030606080801--