Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125212 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 7DC771A00BD for ; Sun, 25 Aug 2024 14:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724596516; bh=+Spbr/Ox6Qo01a8afc7Tq9hEO5tqZooDU2INJZIlGrQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FGISMIwLnQuUoVPfmKwZlKimav3WSocJWI5JHtweArTz698KiOaOs8dobLzy+BwVp iAx323mKzh5Tv4e3V83G+rYg7N0M4W5a5WJzZAiPmzlbP8EkIoCiUpyBqqchWs9Hyf A365aFm6MQU1Bd6F4eK+LZ+2HDW6WXFRlrlwkCgJWeY24oTbYjokFWR84Me/W+BI6m lRo5CdSOf0l01o84rpZy7P3NM8Vus08VbNy2I69OJ87EJT1KllgfvC/u2BEp6h99rK nk54QlqRMEdefyCxDR93VHvSvasmCXe9I3EftFEyYYoo4q7I6p7P6T0jsRmyLwITo5 HiNkS+BwGfONA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7E17118006F for ; Sun, 25 Aug 2024 14:35:15 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 14:35:15 +0000 (UTC) Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-5d5d0535396so2123563eaf.1 for ; Sun, 25 Aug 2024 07:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724596402; x=1725201202; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dmeX8U4VbKcFMrJktZZWImmSH3h8b9kqfKMmKXpgwwk=; b=KiRSvwyRh4bLWWmQxg6+myTsIijmhGHpDZfakUQ5q6UX3kFTTiOKfzNRCZT6QsQx// JulqxE0yL9yDhZPaOjMAi0KRnKLrRPD9LDZZG19OzGvPnlhK1oDoVDuacro0jyiT1Bod FfZdCkju+h+4wOXx4ETWux5yIa1X3mmYPwqhtfwkWb2AzzXwYvWqiEqKjxRtvULJN6vD SeaX/2s+XV5joVnUDBiphinPvrXOuQWz4RRfOXp1WMXPFAbEqlSadPWH1opNOEog7saz Nhvg0cfKHBeN0F9beRF2DpjzmC++a5xE7LHDJlZQINTWv6KzTfa7FzhpqYFz1+E4Htjn u2Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724596402; x=1725201202; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dmeX8U4VbKcFMrJktZZWImmSH3h8b9kqfKMmKXpgwwk=; b=ujccpz8NDo0o/qNilpF9WoQB/VvCvfSPqmvMnfpUAN6iX6evOxdybFt2uoG9yhdxE0 3YGgHMs87wnPROZuyQKsgWgsq8eryoIwJ09QJzWRUOfM80qfC5OE1VuCtPqqfkOOd7XY OsALYYOsLBXR/k0DGh7NbUEoaHalyqt4voK3v9mcOAp4G4BJV+Vc+BVWsU4Qx6WulNGI d5voWsD8iakWpxs0LTAPNBJYCMd8nwyvUipUP3brqn/NFRbaJWXvT219JMm77XqGWWO5 B/ucm8XtjYtRCLzEjEOySwreonJV/X89rlSdK35iNUaYfLT0MR3DOOvgQ5L/ORkyF2I5 TRNw== X-Forwarded-Encrypted: i=1; AJvYcCUWBy8eDw71iJ9XngcKnhVR91r/qtLr4zWhvXQdJJcvkusZlAQMzO+fmISjIkYcIR5HeuSgpp8vxnE=@lists.php.net X-Gm-Message-State: AOJu0YznSQcDdSq6qPckDkr1bb1DI8f7IwNrKm8VeF8KXBn1BQaWxwXV on+VgXWBkSHqEnF6wiCLumPMUjxdNmHX216wF6sBJpx2/pRmA2nBG7ZTve06fT12pzhUm98bPYe h9exuqI6s/fwlxHSbmAVVxZQr7O8vkQ== X-Google-Smtp-Source: AGHT+IF+57l/PsWdzNXcJMroDGms+L94p/JnB2MMKzxe0ck4UN+4p5/30fCtRoIfkFnGvK1OpBiVt15bV4gRCXS21YU= X-Received: by 2002:a05:6359:459d:b0:1ac:625f:9d4d with SMTP id e5c5f4694b2df-1b5c22e2c7amr959687455d.23.1724596401965; Sun, 25 Aug 2024 07:33:21 -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> In-Reply-To: Date: Sun, 25 Aug 2024 09:33:12 -0500 Message-ID: Subject: Re: [PHP-DEV] [RFC] Default expression To: John Coggeshall Cc: Bilge , PHP Developers Mailing List Content-Type: multipart/alternative; boundary="000000000000eb942e062082e36d" From: mweierophinney@gmail.com ("Matthew Weier O'Phinney") --000000000000eb942e062082e36d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Aug 25, 2024, 9:06=E2=80=AFAM John Coggeshall = wrote: > > > On Aug 24 2024, at 12:49 pm, Bilge wrote: > > Hi gang, > > New RFC just dropped: https://wiki.php.net/rfc/default_expression. I > think some of you might enjoy this one. Hit me with any feedback. > > > Seems like you are missing an option for your theme example, which would > be to simply extend the Config class? > > While I can see the value in the concept of default , I think it's a > mistake to allow default to be used as a generic operand as shown in the > RFC appendix. It seems to me that the whole point of something like > default is to not have to worry about what the upstream API wanted for > that value, but the second you start allowing operations where default > is an operand you've reintroduced the problem you were trying to avoid if > the upstream API were to change the type of what default ultimately > resolves to. Worse actually because now I have no idea what default is > when I read code without having to dig up the upstream API. > If the underlying API changes the argument type, consumers will have an issue regardless. For those cases where the expression is simply `default`, you'd actually be protected from the API change, which is a net benefit already. This also protects the user from changes in the argument names. > Other thoughts here are what happens when default resolves to an object > or enumeration or something complex? Your original example had CuteTheme = , > so can you call a method of default ?? I could entirely see someone doing > something like this for example: > > enum Foo:string { > // cases > > public function buildSomeValidBasedOnCase(): int { // ... } > } > > F(MyClass::makeBasedOnValue(default->buildSomeValidBasedOnCase())) > > IMO most operators listed in the appendix should be disallowed. I can see > the value of default | JSON_PRETTY_PRINT, but I am pretty strongly > opposed to the idea of introducing a "conditional based on the default > value of an upstream API call" concept of default >=3D1 . > > > --000000000000eb942e062082e36d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sun, Aug 25, 2024, 9:06=E2=80=AFAM John Coggeshall = <john@coggeshall.org> wrot= e:


On Aug 24 2024, at = 12:49 pm, Bilge <bilge@scriptfusion.com> wrote:
Hi gang,

think some o= f you might enjoy this one. Hit me with any feedback.


Seems like you are missing an option for your theme ex= ample, which would be to simply extend the Config=C2=A0 class?=

While I can see the value in the concept of default=C2=A0, I think it's a mistake to allow default=C2=A0 = to be used as a generic operand as shown in the RFC appendix. It seems to m= e that the whole point of something like default=C2=A0 is to n= ot have to worry about what the upstream API wanted for that value, but the= second you start allowing operations where default=C2=A0 is a= n operand you've reintroduced the problem you were trying to avoid if t= he upstream API were to change the type of what default=C2=A0 = ultimately resolves to. Worse actually because now I have no idea what default=C2=A0 is when I read code without having to dig up the ups= tream API.

=
If the underlying API changes the argument type, consumer= s will have an issue regardless. For those cases where the expression is si= mply `default`, you'd actually be protected from the API change, which = is a net benefit already.=C2=A0

This also protects the user from changes in the argument names.= =C2=A0


Other thoughts here = are what happens when default=C2=A0 resolves to an object or e= numeration or something complex? Your original example had CuteTheme<= /code>=C2=A0, so can you call a method of default=C2=A0?? I co= uld entirely see someone doing something like this for example:

enum Foo:string=C2=A0{
=C2=A0=C2=A0=C2=A0 // case= s

=C2=A0=C2=A0=C2=A0 public function buildSomeValidBasedOnCas= e(): int { // ... }
}

F(MyClass::makeBasedOnValue(default->buildSomeValidBasedOnCase()))

IMO mos= t operators listed in the appendix should be disallowed. I can see the valu= e of default | JSON_PRETTY_PRINT,=C2=A0 but I am pretty strong= ly opposed to the idea of introducing a "conditional based on the defa= ult value of an upstream API call" concept of default >=3D1=C2=A0.


--000000000000eb942e062082e36d--