Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112437 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50029 invoked from network); 6 Dec 2020 00:49:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Dec 2020 00:49:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5399A1804C3 for ; Sat, 5 Dec 2020 16:17:45 -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=-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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 ; Sat, 5 Dec 2020 16:17:44 -0800 (PST) Received: by mail-ot1-f52.google.com with SMTP id x13so1575874oto.8 for ; Sat, 05 Dec 2020 16:17:44 -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:content-transfer-encoding; bh=h8HSgIE6FLpuk/CGpY0fqhPol3k7OtkwxkhmdhL1uHU=; b=HctchYvKHnep0Ce1R9//kSMDAt1cl0Z/YH41lf4xUyFRqi672+UwMNSrXhTg3HaRKC NidD0+5QlrjMJQjIYBuBDHaHxklClXY75r9ozKowe5AU39YwFd+6WZQ48820zQYVbn95 xlw+QJQcWW6YImG7UhZIiNTxBNTIDGEWi2cLvzRX4e7xo078ZQeKBgteWlwNCqKDasZB jpP4DpME69ZbyFAOXBi1Kf5jFTHzzIDwMVpq4cQs7jhJX7puUP8IRkBtnIpqvQrzJBXR 6sXnxFtgh+vLRS45YmgRjtDYiI0iOMaLWKofwk9dSdCb2rrgqlXhEB4FxoTs07/VQgDZ WgSQ== 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:content-transfer-encoding; bh=h8HSgIE6FLpuk/CGpY0fqhPol3k7OtkwxkhmdhL1uHU=; b=MFDKFJS96eF7gw1ZlgNBkx8if2CUHkSIt+viguwSaTRr6PY8Hdm6Ik4kQ3ASNItQaP d28us6V2SKcHmjROUB7MxbTae5r9ystJ9Tpt2TGIA+n2/40q2ApxBvm5rifc2CQHgIJo FdlsO9AV8nAXhy5iOl03rymkD0758OMK+yXeu/Wp0baAXlhWS6H9AgIiYMUcxYnu5GOm ji2ZRzGhnAfis3a6LBa+RQH2lufun3MMScbUsyOy+I7sKHHv3qASMZt4FKDV4oZ4FvE0 7OSwLwll48JWOYkc7db55l31p9rggCz/NVTB5itUcpcTg+QS4bIX/og4hHS5UnVQy9YP /kAg== X-Gm-Message-State: AOAM530Xk/Bh8hJZv4hgTqhDC59Jg0wofjH9Z4tB52eJzDGbdPL/QGw7 Jwq4nquIJePJx73p9S7mysgsOLz5fhYShxK26Q== X-Google-Smtp-Source: ABdhPJzSWrogWU9yKz0FQ7O3CUDpyv6/M7brbxXEG//iUk1VkK9e+q57fIfxMRMcXzIiDwvFxMkd+yA83iesYlNuQo4= X-Received: by 2002:a05:6830:22eb:: with SMTP id t11mr8764514otc.114.1607213863185; Sat, 05 Dec 2020 16:17:43 -0800 (PST) MIME-Version: 1.0 References: <32277b43-079d-4cd7-a159-8ad555096742@garfieldtech.com> In-Reply-To: <32277b43-079d-4cd7-a159-8ad555096742@garfieldtech.com> Date: Sat, 5 Dec 2020 16:17:30 -0800 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Enumerations From: paul.crovella@gmail.com (Paul Crovella) On Fri, Dec 4, 2020 at 7:00 PM Larry Garfield wrot= e: > > > Dec 4, 2020 7:37:51 PM Paul Crovella : > > > On Fri, Dec 4, 2020 at 3:25 PM Larry Garfield = wrote: > >> > >> Greetings, denizens of Internals! > >> > >> Ilija Tovilo and I have been working for the last few months on adding= support for enumerations and algebraic data types to PHP. This is a not-s= mall task, so we've broken it up into several stages. The first stage, uni= t enumerations, are just about ready for public review and discussion. > >> > >> The overarching plan (for context, NOT the thing to comment on right n= ow) is here: https://wiki.php.net/rfc/adts > >> > >> The first step, for unit enumerations, is here: > >> > >> https://wiki.php.net/rfc/enumerations > >> > >> There's still a few bits we're sorting out and the implementation is m= ostly done, but not 100% complete. Still, it's far enough along to start a= discussion on and get broader feedback on the outstanding nits. > >> > >> I should note that while the design has been collaborative, credit for= the implementation goes entirely to Ilija. Blame for any typos in the RFC= itself go entirely to me. > >> > >> *dons flame-retardant suit* > >> > >> -- > >> Larry Garfield > >> larry@garfieldtech.com > > > > I'd like to see the specific reasons for the restrictions listed in > > Comparison to objects[1]. In general if something's value is even > > debatable then the default position should be to remain consistent > > with the rest of the language. It should take a strong argument to > > introduce any artificial limitation and it's useful to have that in > > the RFC. > > > > [1] https://wiki.php.net/rfc/enumerations#comparison_to_objects > > > The reasoning general comes down to one of 2 things: > > * they involve state, and enum cases have no state. They may get reintrod= uced with tagged unions, but for now methods relating to state would just b= e confusing. > * we couldn't figure out what possible use they'd have (like static metho= ds on cases, which without data are exactly the same as normal methods.) > > --Larry Garfield Thank you for updating the RFC. > enum cases have no state Unless there's a bit left out from this RFC this is not completely true, you've just limited them to annoying ways of working with data, e.g. static variables. > static methods on cases, which without data are exactly the same as norma= l methods This is an argument against instance methods, which you kept, rather than static methods, which you didn't. How is this division anything but arbitrary? > Constructors - Not relevant without data/state. > Destructors - Not relevant without data/state. This doesn't explain the need to remove them. What problem do they cause? > Enum/Case constants - Not necessary as methods fulfill the same use case. How is this specific to enums? Why is it necessary to add this inconsistency to the language in this RFC? What happens to constants inherited from interfaces? > Enum/Case properties - Not necessary as methods fulfill the same use case= , plus we want to avoid state. > Dynamic properties - Avoid state. Plus, they're a bad idea on classes any= way. > Magic methods except for those specifically listed below - Most of the ex= cluded ones involve state. Again, what is it particular to enums that necessitates adding these inconsistencies to the language? I get that *you* want to avoid state, but how is that an enum thing rather than a you thing? What happens to properties gained from traits?