Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112459 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60922 invoked from network); 7 Dec 2020 16:27:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Dec 2020 16:27:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C8D8D1804CA for ; Mon, 7 Dec 2020 07:56:40 -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_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-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 07:56:40 -0800 (PST) Received: by mail-wr1-f51.google.com with SMTP id y17so3825475wrr.10 for ; Mon, 07 Dec 2020 07:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=hV+JkkFYXBfmnVlZyThSb+1TrMCSB1re8lrs/1nOLx8=; b=lvrPDlN2+e/oUPmJ2m9Fh+BFqnriv8GA/tp6TE2fapVvjwdVu0OLzFgKTbjSFvW1sC NIEktbPUQQY3WQMW5zqjlTyEAA9wNmGzfmv+RxFIesHTY0neQlwDMcZf6VszuI9oDppK /QzybitMKAFi9ZvFQ25Wzf7L84CnQ1sXxfepBEgM3nJkmzZ3a0GZEUqhoBOitivCGkCM OcLDrI7mmJHYbp8LSioDgqih73TNv2/PDAAzI3YYxhfU7svAVX3i7zHzKYH9I5pkbVUx u7pxWC4clioYO4HWZe2eBRU7su9PtVGDlip+w+UVl5GTnqcNq5zILUDNfXh7FpwSn6G8 1GVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=hV+JkkFYXBfmnVlZyThSb+1TrMCSB1re8lrs/1nOLx8=; b=uBrhOFN/POIQYWVHVgDexI3LLIdyx8WiyF5It/X1+vFuK0r0BE070rVT/XkufeWWbq 99AKE13Qa6j35uDVqsTSlgLLvEVV2qXReynccLaNCy9EtBvkW4A+slHrGl8hBlEziiif FmZr1uXRJDYlcvSxR45Mw8WlZjLx+INg9H/QJnzhqqP5q6Yn2cgmYfPb4S4BodRX9Q1a d0V01eel2XQ7ZYDFOTwzYAf4SlYfaUtbX2tS5bszREridxxyX18K0rUo1A3Adn+01yXg Z41PbfGQrrK1f0+K2l8lTZkp3NJWpU6JBb1psm574erCVxnWY27gqCLsWMYBB5SyZaKV k1ow== X-Gm-Message-State: AOAM533Gi4AF+UnaHKS4VN3QWZJbnKjpCEkmXGDAwRSRjFI39sQypRit fpvkVJXgh6eXNswOWHx5ehCUYokSShw= X-Google-Smtp-Source: ABdhPJza/0tBQUNKiWJJEINeNLRSEniM+nOSVRFxzlWFrhIkxr0OzEM3y5PcTRKAGYU2cQdFMgqNAA== X-Received: by 2002:adf:9d49:: with SMTP id o9mr20908789wre.413.1607356597320; Mon, 07 Dec 2020 07:56:37 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id t184sm15716619wmt.13.2020.12.07.07.56.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Dec 2020 07:56:36 -0800 (PST) To: internals@lists.php.net References: <244f66fb-81c3-4cf7-a0b5-0a3233e3b9e1@www.fastmail.com> Message-ID: <48a411eb-3306-4923-7a9f-39b045240f38@gmail.com> Date: Mon, 7 Dec 2020 15:56:35 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <244f66fb-81c3-4cf7-a0b5-0a3233e3b9e1@www.fastmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Enumerations From: rowan.collins@gmail.com (Rowan Tommins) On 07/12/2020 15:26, Larry Garfield wrote: > Assuming it's feasible to do, what do people feel about supporting that? IMO, cases(), from(), and values() need to be kept no matter what as they're more self documenting and can be passed around as callables. So the question is just whether we should also try to add casting as an alias to those operations. From my experience answering questions about SimpleXML on Stack Overflow, I can confirm that people find magic behaviour of (string) hard to discover and understand, and it's not uncommon to see someone write $foo->__toString() because they're more familiar with methods. That's even more true for other casts, e.g. (int)$foo and (float)$foo, which can be supported by built-in classes but not userland ones, so are even less discoverable. I can see the appeal of overloading cast syntax, but I would personally be on the "just use explicit methods" side. Regards, -- Rowan Tommins (né Collins) [IMSoP]