Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112479 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54367 invoked from network); 9 Dec 2020 21:14:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Dec 2020 21:14:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 59A511804D1 for ; Wed, 9 Dec 2020 12:44:20 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 ; Wed, 9 Dec 2020 12:44:19 -0800 (PST) Received: by mail-qk1-f173.google.com with SMTP id 19so2653777qkm.8 for ; Wed, 09 Dec 2020 12:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=6dcUDzK8XuFTwaa9yuffZ5SDT3ET/WZ4WLRgSLWPFYo=; b=DUFoamoucgphj2jgDDKx65qwO1iR3SWOzT6UZBhTrvMeCGHyv0ZFqwBnaDfKR+Zq8S 1nmIaxGGKegS0++Fus2WNtcvbog7jHuflz23bHHblJfQZctDhnoXmSuE1F5nMhbaHXJ1 dulqjav6dQxBy7D0G5At094ofVR4jg8o0WlzkrosIQt9oGJPeH6XtkVjM/1/s2SMjXs/ nZHJRU9m2Ny9NkXCvuf9qGglgAAXKB7dba3Z6t2gxfepvEt74nJChmWQsMW0KKDglcvL hYALTpWLXp5Z/1PJET9xXNdeXts7i/ujXbS7FDAzhLroZihOFoiIE6c/PO7A75Y6wPT+ rMBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=6dcUDzK8XuFTwaa9yuffZ5SDT3ET/WZ4WLRgSLWPFYo=; b=j61qnls11X+AHiN2rX7QqYywV/O7vmz2OhgSwbrIHIM1IuevRDgULAFag6u/PnkGuH XPiYWrHoPxSJhqhiaQelzrmMiNQSjJ67vgKDR5YpS2PBbCRswgJjyj1ny37OXz1hzzDc Y0mehUuUgYToIHI+CttBJkcz43auHmZRs6vi6st1BI8zrIFCCgkB8o89ofBEjNcNCZFx EbarBtJTaLDHZHGoDZHeTe7NwaKeMtL8uuczg5JuTvTB55camHrIjNmDN3VQKZS9LbU4 GY/fkNQNyS7f/Ny/GL72aE0R3ln+u4gs3jmDY/UvlUzAHs+0ndpA+fRdawvR5W26DsBo +/6g== X-Gm-Message-State: AOAM533cE9CWhZhKj9ik7S2S65KxgRkOFjwF5DhmA4FI1P0VlyCr0OYJ 5d6P6Pmc6GSUaHKW7i3OIaGGTg== X-Google-Smtp-Source: ABdhPJyHBUANuBWAO9SF3dmMi0p0K3+Dhf/RMFRxu8EFIv4vszR8dhTsEBH2gM9GeHYAbscOPveggw== X-Received: by 2002:a37:2d05:: with SMTP id t5mr5169168qkh.187.1607546657368; Wed, 09 Dec 2020 12:44:17 -0800 (PST) Received: from [192.168.1.226] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id u15sm1897827qkj.122.2020.12.09.12.44.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2020 12:44:16 -0800 (PST) Message-ID: <2A21EBAE-85A6-46BB-8261-357A29756DD9@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_F446950B-8640-4367-8ABE-0F2768E55040" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Date: Wed, 9 Dec 2020 15:44:14 -0500 In-Reply-To: Cc: Larry Garfield , php internals To: Benjamin Morel References: X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] [RFC] Enumerations From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_F446950B-8640-4367-8ABE-0F2768E55040 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Dec 9, 2020, at 3:29 PM, Benjamin Morel = wrote: >=20 > On Wed, 9 Dec 2020 at 19:48, Mike Schinkel > wrote: >=20 > 5. Someone else mentioned shortcut syntax, which I would like to = mention again, although I realize implement details might make this a = non-starter. =20 >=20 > So if I have a function that accepts a Size from above, e.g.: >=20 > function show(Size $size) {} >=20 > Then it would be great if we could call the function like this since = its parameter was type-hinted: >=20 > show(::Medium)=20 >=20 > Rather than always having to write: >=20 > show(Size::Medium)=20 >=20 > So can we consider a shortcut syntax? >=20 > I'm not sure what value a shortcut syntax would bring, but it would = surely break, or at least make ambiguous, union types: >=20 > function show(Enum1|Enum2 $value) {} > show(::Medium) >=20 > Which enum would Medium resolve to? Good question. =20 What *could* happen is: 1. It could resolve to the Enum that has a ::Medium,=20 2. Or it could be disallowed for union type hints (probably the better = option as adding a "Medium" to the other enum could inadvertently break = code that calls it.) 3. This suggestion could just be tabled. Again, I am just asking if this is something we could consider because = it would be nice to shorten line length in cases where expressions get = really long. Maybe a different question could be if a "use" statement could empower = making explicit shorthands/aliases? -Mike P.S. I completely understand if either of these things are out of scope = for this RFC. --Apple-Mail=_F446950B-8640-4367-8ABE-0F2768E55040--