Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125267 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 6D6751A00BD for ; Mon, 26 Aug 2024 11:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724672317; bh=8xVJbQeBk75iuTC6frexZ96Awjq4uMAlRPmHOlwxp00=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VHJwB8YxPilmc3oQ1/Oe8N3z3hpnKQXeUe1qyi41P9Kw3derWAbcD5ifqX3eayyza 8LUNKGOcoOc39Pr4a2gHN35LNYiwduuHJ5McT75dGu+aXhvy1Jpg9s1Ef4bUZ+gZjE 0ihCQgg7eHWwbuKFYCP154BqYSbRZ1tbO0GjZTavNSiboTNABQbf9CSU3n/SsUxmef r71VW5sdgxCcdbdoa3YGuBkM5wWBbUNVjPeHfE5rL3hXdWm0AFs1gmvYIkHhvRQ7Np 4oV9GbULTpNEkeFMPhz0yPF1qcQgNtnnweh4/q+oLLTgvIGTNrPFBgBzDVjtC1lr4L tB2b1m/+UDGVQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5174218007E for ; Mon, 26 Aug 2024 11:38:36 +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 ; Mon, 26 Aug 2024 11:38:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4WspY50wdVz1DPl2 for ; Mon, 26 Aug 2024 13:36:41 +0200 (CEST) Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 4WspY45YsPz1DPks for ; Mon, 26 Aug 2024 13:36:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=givoni.dk; s=unoeuro; t=1724672201; bh=8xVJbQeBk75iuTC6frexZ96Awjq4uMAlRPmHOlwxp00=; h=References:In-Reply-To:From:Date:Subject:To:Cc; b=CdgTDb6qMi5l3aDg2NOa1WVpTKL8mZO10wjr9Ci8IJgAfjFmt76XPV68ZPusKOMAO ry7nKCGNyfd4PTVwihLTECFdthCR4cuA4rqLs7rS6JaIHC1u3O8rOVe91fFkLt+Xsr P5lm6Sa6Gt1UzZXLsk1PsCTsvpbI/95U2pFySVP8= Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-6b59a67ba12so38283317b3.1 for ; Mon, 26 Aug 2024 04:36:40 -0700 (PDT) X-Gm-Message-State: AOJu0Yzouk5OhL1kNExGq9viDv6YWRsEQ2IBH3rhMX5OsoEXKxwR6TwW +CDFU1P9kJHcAON/1M8P61GLsrxAvvTFp7rUGx/pOgG7sLTTmcgYCiS7JWcFO7oOPtodxjRHeso cu+5U8iQc4iEnCS+vkzAaRiJposQ= X-Google-Smtp-Source: AGHT+IEeqd/gz/GA78mzgibcsbvk1/6glqFukW7FqXVUjRuh75pIjjB9SNNRNsypJpfv9XjbcijsAAJlCvANVCLJTl8= X-Received: by 2002:a05:690c:f01:b0:65f:aa06:13ab with SMTP id 00721157ae682-6c62538d6c7mr118751037b3.1.1724672199552; Mon, 26 Aug 2024 04:36:39 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> <0cfd3a28-3cb0-4478-85fb-cf086d8e5c66@app.fastmail.com> <3e0d031e-256f-47cd-9a2b-dcdc760f5498@scriptfusion.com> <6afeb23a-867f-457d-9b13-fdf5af02c31e@scriptfusion.com> <928d6c8c-c969-4d55-82ff-5da8fc3d3035@scriptfusion.com> <73301950-03e7-4f3c-9fab-402645f77272@gmx.de> In-Reply-To: Date: Mon, 26 Aug 2024 13:36:28 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PHP-DEV] [RFC] Default expression To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000cf021a0620948913" From: jakob@givoni.dk (Jakob Givoni) --000000000000cf021a0620948913 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Aug 26, 2024 at 12:49=E2=80=AFPM Rowan Tommins [IMSoP] wrote: > On Mon, 26 Aug 2024, at 10:14, Bilge wrote: > > You're absolutely right, I would be interested to see any viable patch > > that effectively implements a set of restrictions on how `default` may > > be used. Requesting it be done at the parser level was not meant as a > > gotcha, that's just how I (with my lack of experience) would have > > approached it, but certainly trapping cases in the compiler is equally, > > if not more valid and/or practical. > > Another approach that occurred to me was in the executor: rather than > evaluating to the default value immediately, "default" could resolve to a > special value, essentially wrapping the reflection parameter info. Then > when the function is actually called, it would be "unboxed" and the actua= l > value fetched, but use in any other context would be a type error. > > That would allow arbitrarily complex expressions to resolve to "default", > but not perform any operations on it - a bit like propagating sqrt(-1) > through an engineering formula where you know it will be cancelled out > eventually. > > I 100% agree with this. "default" should not evaluate to a value before sending it as an argument to the function or method. I understand from what the RFC author wrote a while ago that doing so (evaluating to the actual default value using reflection) was the easier and perhaps only viable way at the moment, but if that's the case, I don't think the value of this RFC justifies doing something like that, which to me seems like a hack. For those already expressing interest in being able to modify a binary flag default parameter using this "trick", I still don't think it justifies this RFC. In my opinion, functions that accept multiple arbitrary options by compressing them into a binary flag have a badly designed interface to begin with. So, my 10c: Make "default" a pure keyword / immutable value if possible, or reconsider whether this feature is really worth the fuss. Best, Jakob --000000000000cf021a0620948913 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Mon, Aug 26, 2024 at 12:49=E2=80= =AFPM Rowan Tommins [IMSoP] <ims= op.php@rwec.co.uk> wrote:
On Mon, 26 Aug 2024, at 10:14, Bilge wrote:
> You're absolutely right, I would be interested to see any viable p= atch
> that effectively implements a set of restrictions on how `default` may=
> be used. Requesting it be done at the parser level was not meant as a =
> gotcha, that's just how I (with my lack of experience) would have =
> approached it, but certainly trapping cases in the compiler is equally= ,
> if not more valid and/or practical.

Another approach that occurred to me was in the executor: rather than evalu= ating to the default value immediately, "default" could resolve t= o a special value, essentially wrapping the reflection parameter info. Then= when the function is actually called, it would be "unboxed" and = the actual value fetched, but use in any other context would be a type erro= r.

That would allow arbitrarily complex expressions to resolve to "defaul= t", but not perform any operations on it - a bit like propagating sqrt= (-1) through an engineering formula where you know it will be cancelled out= eventually.


I 100% agree with this= .
"default" should not evaluate to a value before sendi= ng it as an argument to the function or method.
I understand from= what the RFC author wrote a while ago that doing so (evaluating to the act= ual default value using reflection) was the easier and perhaps only viable = way at the moment, but if that's the case, I don't think the value = of this RFC justifies doing something like that, which to me seems like a h= ack.

For those already expressing interest in bein= g able to modify a binary flag default parameter using this "trick&quo= t;, I still don't think it justifies this RFC. In my opinion, functions= that accept=C2=A0multiple arbitrary options by compressing them into a bin= ary flag have a badly designed interface to begin with.

So, my 10c: Make "default" a pure keyword / immutable value= if possible, or reconsider whether this feature is really worth the fuss.<= /div>

Best,
Jakob

=C2= =A0
--000000000000cf021a0620948913--