Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125306 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 AE3171A00BD for ; Tue, 27 Aug 2024 07:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724744927; bh=iuei2GOA86sFdNwUL7/HUTvKunjBM8sCZqIwyTwtxA0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aoo62tKImVaNT9c0nid6VujhOsouTjotUfWbp0IhwnRb1XQhhPXXKUIsv0vaMH190 f6tuxua0DHUzFFRYtH/fDfhJsAjLVxLnWBHC56VRWAC6Q3BqcaHaabwhpEBXWWborK 54BuqLcQUs01HP4rav8Eg10H2Vf6DMfwiOAZIReownvY1istTl6dKFOXaN2x7kSy/x LDY8Cg8zIoYuksZfwDw+EpmFGw/JcHAto/32+zCH/7uEL2naypvjsfUFqJypDLqphc u+gys1XhAvwnHBqR00Uu9SCw8RCAMZC7+zcgJhhtMgwc3417NWx+TnahGyiOKudbs7 PeKN3/c8xilsw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1263E180034 for ; Tue, 27 Aug 2024 07:48:46 +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=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (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 ; Tue, 27 Aug 2024 07:48:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4WtKPQ42QVz1FRm8 for ; Tue, 27 Aug 2024 09:46:50 +0200 (CEST) Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by smtp.simply.com (Simply.com) with ESMTPSA id 4WtKPQ1NYWz1FXSn for ; Tue, 27 Aug 2024 09:46:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=givoni.dk; s=unoeuro; t=1724744810; bh=iuei2GOA86sFdNwUL7/HUTvKunjBM8sCZqIwyTwtxA0=; h=References:In-Reply-To:From:Date:Subject:To:Cc; b=Ivj1ES8AQqY+6JhrBvKaBmKF1ZEDUkKrY4TUTnzcmOQaM0poWZ0hUHEFSCLNx7qQa DO2vTL2Kz5FiCLAQr0pWEkos+BI5ZN7pDAcTdPiK2x6OZ0cJP1hHC97r5X7p5S2pmh 5P3KYr8fPEy73eMP9duGDzHeD/L9nqSR0gorb4Ck= Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6c130ffa0adso52719787b3.3 for ; Tue, 27 Aug 2024 00:46:50 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCV+IesnYwlLLr6BS0VY1UCJb0eOpgNwmalWpBXKmbOkw4/Wii6NyPeMdYPlCFHtRKKpXSpaBSbwsYA=@lists.php.net X-Gm-Message-State: AOJu0YyG85TyDGdkF/y7bru7EoCgr0Ap+AjeyMOo76OrCkg/KjiNxugZ 9ZrBadPZTdaGNajTbWeNQ1W+drfz9W1kSqaA/db/FlUjfadqffj8fuGTT05s8AgCxgt3MLlUUcJ Dg9AO2pKX4BY1vbI8qOO/aFKTYD4= X-Google-Smtp-Source: AGHT+IGNgIpWQh6l8LkE1Tcbd/Hg+l4IayCRjql4KQA0B+Dlj670xoxGnl1J7YgXhX71uqb+x5bEUb0J4BCVWFoHWUY= X-Received: by 2002:a05:690c:f82:b0:62c:e6c0:e887 with SMTP id 00721157ae682-6cfb950a938mr25384457b3.9.1724744808924; Tue, 27 Aug 2024 00:46:48 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 27 Aug 2024 09:46:37 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PHP-DEV] [RFC] Default expression To: John Coggeshall Cc: "Matthew Weier O'Phinney" , Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000aa16b90620a5710b" From: jakob@givoni.dk (Jakob Givoni) --000000000000aa16b90620a5710b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Aug 27, 2024 at 6:23=E2=80=AFAM John Coggeshall wrote: > > But let's not just say "no expressions" - I think there's been some > demonstrated value from a lot of these. > > > Honest to god I don't think I've read from one person to come out and say > "no expressions". > Well... I think it's causing more confusion than insight when we talk about blanket "expressions" in the context of "default" here. Expressions in function calls were always permitted: foo(1+2); // Evaluating an expression and sending the result as the value of the first parameter The question is whether to allow OPERATIONS on "default". Notice the difference here: 1. foo($userValue ?? default); // No operations performed on default, very useful feature! This is still an expression involving the keyword default. 2. foo(default + 2); // "default" must evaluate to a value so we can perform operations on it. This is also an expression, but I would not be in favor of this behavior. So the real 3 options are: 1. No operations on "default". Treat "default" as a placeholder and send it as such to the function. Any expression that evaluates to "default" is fine. My opinion: Useful. 2. Allow any operations on "default". Extract the value and treat "default" as any other "variable". My opinion: Dirty, possibly useful to some, but I wouldn't use it, and would rather not find it in my code. 3. Allow SOME operations on "default", and block others. My opinion: Nightmare. Both discussing which operations and why, documenting it and maintaining it. I'm out :-) So let's STOP talking about yes or no to EXPRESSIONS and START talking about yes or no to OPERATIONS. Best, Jakob --000000000000aa16b90620a5710b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Aug 27, 2024 at 6:23=E2=80=AF= AM John Coggeshall <john@coggesha= ll.org> wrote:

But let= 9;s not just say "no expressions" - I think there's been some= demonstrated value from a lot of these.

Honest to god= I don't think I've read from one person to come out and say "= no expressions".=C2=A0

Well...
I think it's causing more confusion than insight w= hen we talk about blanket "expressions" in the context of "d= efault" here.

Expressions in function calls w= ere always permitted:

foo(1+2); // Evaluating an e= xpression and sending the result as the value of the first parameter
<= div>
The question is whether to allow OPERATIONS on "def= ault".
Notice the difference here:

= 1.
foo($userValue ?? default); // No operations performed on defa= ult, very useful feature! This is still an expression involving the keyword= default.

2.
foo(default=C2=A0+ 2); // &= quot;default" must evaluate to a value so we can perform operations on= it. This is also an=C2=A0expression, but I would not be in favor of this b= ehavior.

So the real 3 options are:
1. N= o operations on "default". Treat "default" as a placeho= lder and send it as such to the function. Any expression that evaluates to = "default" is fine. My opinion: Useful.
2. Allow any ope= rations on "default". Extract the value and treat "default&q= uot; as any other "variable". My opinion: Dirty, possibly useful = to some, but I wouldn't use it, and would rather not find it in my code= .
3. Allow SOME operations on "default", and block othe= rs. My opinion: Nightmare. Both discussing which operations and why, docume= nting it and maintaining it. I'm out :-)

So le= t's STOP talking about yes or no to EXPRESSIONS and START talking about= yes or no to OPERATIONS.

Best,
Jakob
=C2=A0
--000000000000aa16b90620a5710b--