Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125210 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 56F581A00BD for ; Sun, 25 Aug 2024 14:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724594777; bh=MbICdOeVsUgLB7zymUPOuMmEOXZUbOzdNDuRjz32pOc=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=hM9ALB+v9nL5hgtCJj24fn8vqOTZc2wPIyeub/P1+xonoHQdmeOop9XbU+0gY9W4N er6db9WtFYngIDA6y4RFq7t7sqbxo+Mb26hXFcYnVFnRXdxwRpIJ/B0Gqn26gGGiaE 1QAKcDAYUrn1b/gOut14YDrNzQqaW5ZZE1YNgbbSAu+L53surpBlr+SBRf2V1E53bZ 5mxeYMPNGJapTpjPwQCpwjbUZEhfgJX71Fi86YW3B7nDIgQlxblz0+QNl4mLFz7o1P tLay/8VDJhpn5A2zQDHawDQC6I+W+4KV+HjFSGX8EzIA0Kb1/CxWJmkyt7duOWyc0Y zI2VCQcEIfxvA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 70E41180082 for ; Sun, 25 Aug 2024 14:06: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_H3,RCVD_IN_MSPIKE_WL,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-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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:06:15 +0000 (UTC) Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-70930972e19so1572071a34.3 for ; Sun, 25 Aug 2024 07:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coggenterprises-com.20230601.gappssmtp.com; s=20230601; t=1724594663; x=1725199463; 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=MbICdOeVsUgLB7zymUPOuMmEOXZUbOzdNDuRjz32pOc=; b=LhBrWlYyy9Rv5YYOn4PLgwu8PidjsmF4hNcId5oafsbbWXcTv+vvteq4qMtoGO7IYp xkYiEhMoToJpZRnoK2eG8h3qBEC3SXk3ayEArr9QhkbXeFFHefMbyQmSJwjnJ5nGhck6 vx+5U1ArGTX2HByRWqJbm2VACH301W+8CioH7nIg+AN7KS/mUzYuDCUdEfTBWY1FLXws 0yj2dTqIrbtl1e0agy62uNXtcVfuFNjpZcpYnOP4AKJPDI6dxeGxOWLlN4svfoXaPSV5 PxHvv8+HxkfinmwLTsiwMfwqmhJ1d7XR+Ppj/aGM5vSmrwyyQ8GASaAuCCgAJcUro5zn spqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724594663; x=1725199463; 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=MbICdOeVsUgLB7zymUPOuMmEOXZUbOzdNDuRjz32pOc=; b=qsC7Nhl3Ucr6eybGzi2Te+JZYuJ6EUersGFJsbCmd+y+CQsppwx2xxKXOz7wXCwv1s ob8sE2f59amWxC26+DxoPyPxPus9AKFylut9AdQMS8aH6Qgt7m/NK1VTbrlIs/5Y+ozE opzBYi10V3okj9ZqWn1YwzWJJhGaNeLkw2mCcOCaFHA48oeutz2mwnhN1bcQ1kzo0Htj PbAiwY46Sx0zWi2fgX0tRAydtO7rWvIDLmDkrLPejUOEPlcrGIkY02Uup1HajtfLhTv7 Qs8qY1OSt36QRGoQZr19L1R77ljY6Vv9m0vvZmIKggjiwNpRr65OpgxoSigZqXgOx5ri OiHw== X-Gm-Message-State: AOJu0YxDP++N+MRwbrz3ggyvHb3okQXbB8YOPO8knvWDVyzFMhk75ME6 DzajNlhJM9P70OQ3yVKJqTsTamyl7OutJOQI7hpLhwdjBiQM2TR3hS3ci5LudMo= X-Google-Smtp-Source: AGHT+IGRbdUEKMkQ3XbaCbjX30cW7QASaChaSzAJkTWArAAho4TKrb0PQt4sIivj+3+c0DmMtYblHg== X-Received: by 2002:a05:6830:7004:b0:708:b083:86c8 with SMTP id 46e09a7af769-70e0ec3a8b8mr8780491a34.21.1724594662752; Sun, 25 Aug 2024 07:04:22 -0700 (PDT) Received: from Johns-MacBook-Pro-2.local ([207.213.210.67]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70e0389170fsm1508730a34.0.2024.08.25.07.04.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Aug 2024 07:04:22 -0700 (PDT) Date: Sun, 25 Aug 2024 10:04:20 -0400 To: Bilge Cc: "=?utf-8?Q?internals=40lists.php.net?=" Message-ID: In-Reply-To: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> 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="66cb39e4_6b8b4567_11f93" From: john@coggeshall.org (John Coggeshall) --66cb39e4_6b8b4567_11f93 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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. 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 >=1 . --66cb39e4_6b8b4567_11f93 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

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

New R=46C just dropped: https://wiki.ph= p.net/rfc/default=5Fexpression. 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=3F
While I can see the value in the concept of default&nb= sp;, I think it's a mistake to allow default  to be use= d as a generic operand as shown in the R=46C appendix. It seems to me tha= t 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 th= e upstream API were to change the type of what default = ultimately resolves to. Worse actually because now I have no idea what <= code>default  is when I read code without having to dig up th= e upstream API.

Other thoughts here are what happens when <= code>default  resolves to an object or enumeration or somethi= ng complex=3F Your original example had CuteTheme , so = can you call a method of default =3F=3F I could entirel= y see someone doing something like this for example:

enum =46= oo:string =7B
=     // cases

    public funct= ion buildSomeValidBasedOnCase(): int =7B // ... =7D
=7D
=46(MyClass::makeBasedOnValue(default->buildSomeValidBasedOnCase()))

IMO most = operators listed in the appendix should be disallowed. I can see the valu= e of default =7C JSON=5FPRETTY=5FPRINT,  but I am prett= y strongly opposed to the idea of introducing a =22conditional based on t= he default value of an upstream API call=22 concept of default >= =3D1 .


--66cb39e4_6b8b4567_11f93--