Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118105 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93772 invoked from network); 27 Jun 2022 11:03:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Jun 2022 11:03:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 03A751804BD for ; Mon, 27 Jun 2022 05:54:30 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 27 Jun 2022 05:54:29 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id i15so16634219ybp.1 for ; Mon, 27 Jun 2022 05:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S6S1PsN+wQ3E9d0PXcYspbMwv/iuCHm6jmka2SgI5wk=; b=T4WKl2QpUiMmqp502ikC1dJ5yQXm3DUPsJfCX42Fc0/WqlsIW+hMo8Rs/76iLSGdvk q8DzmkennCfdgM6Yj9Dud1roU2+jN0WBkP78VIT4WekCkfGeYDR7E3VoGTcmIjT8Aj+0 PtYfLCIEH8hAjrvIJUCbDshSekVWKNxB6JjRuTPBq1kjEtGUJwwcIJ7PrlMKeemuGudH zVgtz/5IUo17Nn2aM13cS0oxVCUmyRmA2rrqNZ7PrLv6ouIi6724ebl7vZFKOMbnNC8/ TxhlpoKXM992dKNKzEkbEZniiwhHPaPThK8mB5JTM5xGEP5ZUFTSb6bsBuB1MI0LpQik nrQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S6S1PsN+wQ3E9d0PXcYspbMwv/iuCHm6jmka2SgI5wk=; b=luwAfKfc0nLhmUDpU6cMN3AheQbjL7SXGuoLgu61nYRdqGMxnE8YuHt9PEEGqoJ2Nj 3tv1ZdiNP6DRoEbi3m4thqBDx1q0wgd7qDgmVzjttmC4JgAEvqXldpDZHk0PRen32nhD 7TRdJfI5eQ6sy6/P5VifFqps6XoXStsPc2xKL05Ihf3t8Qg49iWEwnTC7dU9AW6ECgoS A/d1MhjM44q3uq80vCjhxxJSi0Y0tBOLKbzeRnO2JHPotq994EBR8IFajvpkJipULNOY VykwNBWZHrYoLCyt7hE/cX7J+6B65Fq6nRRYUo5Yuen1KqQOsRhOMUq5rBETbB6N9imv 3TDw== X-Gm-Message-State: AJIora8qJGQFK1LeSpqKFv01hSFQW8QjYTz5YVKtgi+uNGYYcSPqJEpD /UFXoFLdeLUWKZtNaw8oqTrU8915TYb+rqxiHoSAop3Lhi9daA== X-Google-Smtp-Source: AGRyM1sggMJt5IbS/n7ZKP834YKKIYa/kukuBvrmIe4aZS8aekVGqxxV3zbL0kaWJ9vkcdCult4URoKXEQTIqWx9Apg= X-Received: by 2002:a5b:86:0:b0:669:b396:c940 with SMTP id b6-20020a5b0086000000b00669b396c940mr13720732ybp.135.1656334469098; Mon, 27 Jun 2022 05:54:29 -0700 (PDT) MIME-Version: 1.0 References: <6a016333-2be0-4865-b263-29611ecb4c62@www.fastmail.com> <78f26b4d-6f3e-f5e0-3ad5-3a2378ee7030@mabe.berlin> In-Reply-To: Date: Mon, 27 Jun 2022 14:54:16 +0200 Message-ID: To: Rowan Tommins Cc: internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: landers.robert@gmail.com (Robert Landers) On Mon, Jun 27, 2022 at 10:16 AM Rowan Tommins wrote: > > On 27/06/2022 08:38, Marc Bennewitz wrote: > > Now as I have a lot of such classes and I want to make sure all of the > > prefixes are unique so I added an enum with all prefixes and use the > > enum value as constant value as well. > > > > enum IdPrefix:string > > { > > case USER_ID = 'u-'; > > // ... > > } > > > This would never have occurred to me as a design, because I had no idea > that the values of backed enums were enforced to be unique. I'm not sure > if it can be considered "taking advantage of a side-effect", or if > people always expected backed enums to be used that way. > > Ultimately, that's my reaction to both the enum-related RFC currently > under discussion: I don't really understand what backed enums are > intended for in the first place, so find it hard to judge whether > expanding them in a particular way makes sense. If a string-backed enum > can be considered just a unique set of strings, then it really has very > little in common with how I think of (unbacked) enums, but maybe that's > fine. > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > I think it is fair to consider backed enums a "set" vs. "enum." A good use-case for integer-backed enums would be HTTP response codes, however, the standard library only accepts integers (http_response_code(), for example) and it would be nice if it either accepted built-in enums or automatically cast integer-backed enums to int. However, the latter probably makes more sense simply because response codes are changing slightly, and will continue to evolve: https://www.rfc-editor.org/rfc/rfc9110#section-15 (some 4xx codes have been removed IIRC). Robert Landers Software Engineer Utrecht NL