Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125223 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 443AA1A00CA for ; Sun, 25 Aug 2024 16:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724603119; bh=2mmF5EhtODo2kk2emA5PjDbn2CHZKoq9Krvd8vHRoCQ=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=Qr8wErwk+ufg31bHjet+t0VVtZ5m905zZCXEm+ntdxLUwDlN1QoZx3Y1i2Kd1Geam NwFUXzR8kK7v1rdWmgqlsm4X7g5C5JjwQ/Dm6d2MRiQiWqJvkedHsHWJWlilxXTaAR oidUluHYCxG2l3/+XxCn5cVdOyvIpoLnB8EQByNRr3ovNnz9y4uN3cfZEuN9j+EdnG 2+dh51qajN5loiDD/GnucalNmHyiSp4XIqhSC+/MUcakfs26Tkzf1wp6Bc+MT1mT+k ga0TTQywgRPNON91MjgXtRbEh2oT1I//gSIGABLsTo90ChB9YTTd9dmm8y5SUv4Zsl A6GVPhvxhB+ew== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 862FC18038D for ; Sun, 25 Aug 2024 16:25:16 +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=4.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 ; Sun, 25 Aug 2024 16:25:14 +0000 (UTC) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-6b2e6e7ad28so35650557b3.0 for ; Sun, 25 Aug 2024 09:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coggenterprises-com.20230601.gappssmtp.com; s=20230601; t=1724603002; x=1725207802; darn=lists.php.net; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=2mmF5EhtODo2kk2emA5PjDbn2CHZKoq9Krvd8vHRoCQ=; b=uBL+K871UJl8yG2nv0saQVE4QfjqlGLSkeHdAzWRoOntAhYUQ/zblRPfYgD/0iUkoH m+xN+01UwXhCSDKnBQXitkB5mvVvcB9Zzmdqlthh65QpNc6f+qRnH7EhpJJCOOaN0M8S OwkN4FVuW0NvI7APMsp3gjZ6VW6l63XupvSJnd6taMX34EGWRteV0yn7zm/MhfoXYxbU IgABkWOgIGWYESgBxMlpfnCCp0ZSJF/damuvHh/yITNwMsXh7+X0igX4AAPGbGPgZR8i y3Q491c6fm1jIUCqeAdJSDd3KoIrsqI/BkFv0LrQ44i7pjoFAUBsF7rHQ7w+z/QP2hlQ VypA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724603002; x=1725207802; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2mmF5EhtODo2kk2emA5PjDbn2CHZKoq9Krvd8vHRoCQ=; b=t+gnnzC3AUa4Mfynd/Wuzfpo5Yn3wv+O8lMGtBqF9CdWpBmQsIZEpRTOKiU3SRVMsn fubFTZuOF5UR0M0qa0XJoeDCXqb7lKrslRaMYM8SFu1Ao2zT2whkz++L/afNJm25R95M OAHZM7gB3TmTHiKXfViGuWTyf+iMcBTkqqOzjIlHcxO+8h1AU0DJNQ7k20XVjGdZHrE6 J2/L1Q4GvVy2V8zHCjW5EpGqFo+vxpmDh7ij1mdMP082BYXK+B93bQ2cJKNLp3cJ1k5o fGUnQrdQh0TlkwYR0EyuXpy6o5/pIY2E4NQMy6+47YmJQ72HUC9QGfOqfTisEahhCfWy XJAw== X-Gm-Message-State: AOJu0Yy6l52Qrvhgf+EQdc7WuSohvpjJkoujG16N3YMDQTakwRbZRdRf pH6lj/7gdAeZ2VDLev9uyGlrU9skuEExORR6Ut+JgV4FHjE+0YDuTvJuh+3PeYQKxmNhe5ugm6e v X-Google-Smtp-Source: AGHT+IEK3ixocy1kBEhaEb7875/K3RVYUu1HNIyMURjHSj5t8PNeVzze4kbQMDpiRr9A6U4BoEGEyw== X-Received: by 2002:a05:690c:6a0c:b0:664:a47e:8a5 with SMTP id 00721157ae682-6c3075a17ddmr108508247b3.23.1724603001934; Sun, 25 Aug 2024 09:23:21 -0700 (PDT) Received: from Johns-MacBook-Pro-2.local ([207.213.210.67]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b007449sm12348527b3.68.2024.08.25.09.23.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Aug 2024 09:23:21 -0700 (PDT) Date: Sun, 25 Aug 2024 12:23:20 -0400 To: =?utf-8?Q?Rowan_Tommins_=5BIMSoP=5D?= Cc: "=?utf-8?Q?internals=40lists.php.net?=" Message-ID: <9B1A7EFF-1AB3-4DCD-9A14-AF9FD5EE504C@getmailspring.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Default expression X-Mailer: Mailspring Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="66cb5a78_66334873_11f93" From: john@coggeshall.org (John Coggeshall) --66cb5a78_66334873_11f93 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Aug 25 2024, at 11:31 am, Rowan Tommins [IMSoP] wrote: > > > Even then, I look at that list and see more problems than use cases. As the RFC points out, library authors already worry about the maintenance burden of named argument support, will they now also need to question whether someone is relying on "default + 1" having some specific effect? > Maybe we should instead require justification for each addition: > - Bitwise | is nicely demonstrated in the RFC > - Bitwise & could probably be justified on similar grounds > - "$foo ? $bar : default" is discussed in the RFC > - The other "conditions with default on the RHS" in my shortlist above fit the same basic use case > > IMO the operations that make sense in this context are: - Some Bitwise operators: & | ^ - Conditions with default on the RHS: $foo ? $bar : default, $foo ?: default, $foo ?? default, match($foo) { $bar => default } - Parentheses: (((default))) > Beyond that, I'm struggling to think of meaningful uses: "whatever the function sets as its default, do the opposite"; "whatever number the function sets as default, raise it to the power of 3"; etc. Again, they can easily be added in later versions, if a use case is pointed out. I 100% agree. > G((default)->F()); // lol > Special-casing the T_DEFAULT grammar would not only bloat the grammar rules but also increase the chance that new expression grammars introduced in future, which could conveniently interoperate with `default`, would be unintentionally excluded by omission. I won't vote for this RFC if the above code is valid, FWIW. Unlike include , default is a special-case with a very specific purpose -- one that is reaching into someone else's API in a way the developer of that library doesn't explicitly permit. It should not become a fast easy way to inject a new potentially complex dependency which is what allowing a full expression support would allow. The fact that Reflection allows me to pull out a private member doesn't mean accessing private members of objects should be given its own language syntax. Frankly, not only should the op list be limited but ideally it should also only be valid based on the type of the upstream API call (e.g. bitwise operators should only be valid if the upstream API call has a type int ). --66cb5a78_66334873_11f93 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

On Aug 25 2024, at= 11:31 am, Rowan Tommins =5BIMSoP=5D <imsop.php=40rwec.co.uk> wrote= :


Even then, I loo= k at that list and see more problems than use cases. As the R=46C points = out, library authors already worry about the maintenance burden of named = argument support, will they now also need to question whether someone is = relying on =22default + 1=22 having some specific effect=3F

Maybe we should instead require justification for each addition:
- Bitwise =7C is nicely demonstrated in the R=46C
-= Bitwise & could probably be justified on similar grounds
-= =22=24foo =3F =24bar : default=22 is discussed in the R=46C
- = The other =22conditions with default on the RHS=22 in my shortlist above = fit the same basic use case


IMO the = operations that make sense in this context are:

- Some <= /u>Bitwise operators: & =7C =5E
- Conditions with default = on the RHS: =24foo =3F =24bar : default, =24foo =3F: default, =24foo =3F=3F= default, match(=24foo) =7B =24bar =3D> default =7D
- Parent= heses: (((default)))

Beyond that, I'm stru= ggling to think of meaningful uses: =22whatever the function sets as its = default, do the opposite=22; =22whatever number the function sets as defa= ult, raise it to the power of 3=22; etc. Again, they can easily be added = in later versions, if a use case is pointed out.
=
I 100% agree.

G((default)->=46()); // lo= l
Special-casing the T=5FDE=46AULT grammar= would not only bloat the grammar rules but also increase the chance that= new expression grammars introduced in future, which could conveniently i= nteroperate with =60default=60, would be unintentionally excluded by omis= sion.

I won't vote for this R=46C if t= he above code is valid, =46WIW. Unlike include , = default  is a special-case with a very specific purpose -- on= e that is reaching into someone else's API in a way the developer of that= library doesn't explicitly permit. It should not become a fast easy way = to inject a new potentially complex dependency which is what allowing a f= ull expression support would allow.

The fact that Reflecti= on allows me to pull out a private member doesn't mean accessing private = members of objects should be given its own language syntax.

=46rankly, not only should the op list be limited but ideally it should = also only be valid based on the type of the upstream API call (e.g. bitwi= se operators should only be valid if the upstream API call has a type int ).
--66cb5a78_66334873_11f93--