Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112462 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87451 invoked from network); 7 Dec 2020 20:51:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Dec 2020 20:51:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 324F61804D1 for ; Mon, 7 Dec 2020 12:21:00 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 7 Dec 2020 12:20:56 -0800 (PST) Received: by mail-lj1-f181.google.com with SMTP id o24so16466798ljj.6 for ; Mon, 07 Dec 2020 12:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9kVxI1hbPuZ01Wz8whd6sJjajMVMtdlHvNeVeqMlHMA=; b=sIvDlYukY+ituqDi2H8FsLjSuvktUlQyicfittRzTIFBFsoBAgNQ/WM7Fy4VhXRlMB rKP/xaiZ21d7Q2WSaejAVk5xjDtbGT9VX5tEVq3vsDjg/2VaY1ZTKePpMYfCDaJ1hkwE oqyaakP4m6gPMRufBlFK2tA8I7fzvXOmXI5aHKhvWVVdVh7XnvwLh01BXHW/CzpYEu7v pkiCK5SVZPPUZfziW8O1DAz4fKDxMsYQSVXywpWDGPr96IKmBAMuCoNkrsl2fu447VeP P0I4SEl8CUDyr1b0CTp85B9UasoFiZoRj4iggYXfA4/7iPcj2hudUiIRvgq62nQqw1Rn hytw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9kVxI1hbPuZ01Wz8whd6sJjajMVMtdlHvNeVeqMlHMA=; b=XQgWnSUDWM+QIB9NMlNBk5z1YgZuoyd0E4rVonHUAlW2IK4OSph7X7di3pHy2I1thd yfVhzn13cl0TgEj7IkzPhx1MWihjv5gK2MpkTHJJJ8ASK7KiPR5oZ12KFE4ket+3RhfT 7ua3S8e5d2oKne+VYBCypDz0tB/l7xHXb4Oc0hiUxa8w+PDXrOjlyw0iVG2Q03+pYIHp cSt2N5Cw0ZhsbJuUDN6lbFfV3Z/WEP7t2Qjj9IhNAidy1s4xNr00hHdbOdJMEu0B+Qmx flfDXTKjvrD/24vqJuQoKoIMxe+8njdZDHlx83DfnPdx8b4FPlUNZsTqUIUmpgNp6m6l yH9A== X-Gm-Message-State: AOAM531K1LNadcb3JQ6XjYeBLVoOeei3j4Aszuz7lSeKndmMuwT+nppQ XxFCswfJBXejXsJytHDdN2JER5yM8brrgVN4qXkzYSl1kSI= X-Google-Smtp-Source: ABdhPJwHrEV82JVhCV5WNUFEVafv+KXzBvCz86AFO6jp5CStf0QYErx+MQDy9LM4pqLH8d8bO8LPhBi8IcC5wWjFU1M= X-Received: by 2002:a2e:9f55:: with SMTP id v21mr8860663ljk.288.1607372453919; Mon, 07 Dec 2020 12:20:53 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 7 Dec 2020 23:20:42 +0300 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="00000000000023437605b5e590fb" Subject: Re: [PHP-DEV] [RFC] Enumerations From: maxsem.wiki@gmail.com (Max Semenik) --00000000000023437605b5e590fb Content-Type: text/plain; charset="UTF-8" Thank you so much for moving this forward, Larry and Ilija! I myself have tried to draft my proposal at https://wiki.php.net/rfc/enum_v2 which has aspects both similar and different from yours. And "v2" is another indicator that this feature is desired by many, so yay. On Sat, Dec 5, 2020 at 2:25 AM Larry Garfield wrote: > https://wiki.php.net/rfc/enumerations A few comments: * Having to write "case" everywhere is extremely verbose, I can't think of a popular language that requires so much typing in this area. Can the keyword be omitted completely? * Performance concern: I suspect that most developers will not use the advanced features from this proposal and your future plans much, instead they will want to use it in very simple contexts, e.g. "$order->calculateWeight(Weight::Gross)". Would every such call require an object allocation and initialization? What about comparisons, would expressions like "if ($cardType === Suit::Clubs) ..." require a new object? * What do you think about the part of my proposal that allows omitting enum name where it's obvious from context, e.g. "pick_a_card(Clubs)" if the declaration of pick_a_card() requires a parameter of type Suit? -- Best regards, Max Semenik --00000000000023437605b5e590fb--