Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112847 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4331 invoked from network); 12 Jan 2021 01:32:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Jan 2021 01:32:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B531A1804E4 for ; Mon, 11 Jan 2021 17:09:47 -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-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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, 11 Jan 2021 17:09:47 -0800 (PST) Received: by mail-qk1-f169.google.com with SMTP id h4so597766qkk.4 for ; Mon, 11 Jan 2021 17:09:47 -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=dXGandi/yBlF1KVKuxvO5KKy4LNs3USWupTs/jL3zBA=; b=EykAxe60iSnq02haumMbxMDNRTqznODAoqIv2mfc5tbE9VTT824yqcqLmPkE6G5O/x 5QtyJnjNEBksPwUPXn0zfU+/TG9DtT5qvxQB62kSnjEMZcVlwxTeiyqDMKShLVeJUYQD MSlQfiBtXfuMs0zDDE+RHC0IsHAMe2QLvm256l4BTrYUEW1/5ROh9seaiWDTBLVqVkeU u8vJ3z0j2zAdWPmmbTu/9NV6nKXr01lmbFdA98/UZvc9HxTFqYJenBEUOySMsN5GJtF+ s712UiwtZYDJqQLf6ehCZz6zBAR3ESAfsL9aHzw3qSmdJj++sMczhPw9F5zy2hNPFbai bB8g== 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=dXGandi/yBlF1KVKuxvO5KKy4LNs3USWupTs/jL3zBA=; b=taZCQjX/a9CYWpbnaHtBF9GvgGKV0wah2R75AEbgs//0rgqjIfHPANpE6Ki2GVDh9l cZllE2qAo6+NMqfyZq0JplZWtIYs0SHwb8BMLe0aSL3h9b4T6v75ohvEFGcLfDlgA03C BqLasWPt1TPA2W+dlISIg9BkM11WOxRO58j2OVbOgG1CbMzlHhBxNi0gEAoqyjTUWal+ /JVpALLYUyJ6Ftohb0KiAwDOqF59M5v7Pt0BAfm4FZOx+1twNLY7jX5Mj2Lokn6vYfyC h0NESsbd8EPz+WyiPCYawNBXuiHJq/dX9KoytdUIR8UzePc67coDWaEklZyKh35HLPX/ qMog== X-Gm-Message-State: AOAM532jbvFwiXfSiNBQRHu4PdFjnR8qaZeAQKp9SxdYFBYG7DmGaBOR 93CGx1KR63eAVRf8kZxWg+CctzHS4Sm0lqhu X-Google-Smtp-Source: ABdhPJyLOsBikCAqbCNhGDNVI8KCEcn+aGza8nGARdSvIIHuAdamIrYjhmGKi3deKHciJj5VqBjejg== X-Received: by 2002:a37:6713:: with SMTP id b19mr2023870qkc.493.1610413783994; Mon, 11 Jan 2021 17:09:43 -0800 (PST) Received: from [192.168.1.239] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id h25sm552031qtp.80.2021.01.11.17.09.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2021 17:09:42 -0800 (PST) Message-ID: <26074258-B6B5-40EA-A043-E3FAD1FB5365@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_8F78F7CE-18A6-4A2E-9DB9-203C197E789D" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Date: Mon, 11 Jan 2021 20:09:41 -0500 In-Reply-To: <28f44744-4dc5-4cb8-8751-6b66386119fa@www.fastmail.com> Cc: php internals To: Larry Garfield References: <490416F4-7E2F-454F-A317-43212CA6C2D1@benramsey.com> <28f44744-4dc5-4cb8-8751-6b66386119fa@www.fastmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] "TryX" idom for Enumerations From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_8F78F7CE-18A6-4A2E-9DB9-203C197E789D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jan 11, 2021, at 6:52 PM, Larry Garfield = wrote: >=20 > On Mon, Jan 11, 2021, at 2:27 PM, Ben Ramsey wrote: >>> On Jan 10, 2021, at 20:09, Larry Garfield = wrote: >>>=20 >>> On Sun, Jan 10, 2021, at 4:40 PM, Mark Randall wrote: >>>> On 10/01/2021 21:27, Larry Garfield wrote: >>>>> The "a method that begins with try is nullable, so watch out" = idiom is present in C# and Rust, but to my knowledge has never existed = in PHP. That doesn't make it bad; it actually combines quite well with = the null coalesce operator to allow for default values, making a = valueOrDefault() method unnecessary. >=20 >=20 >> I have no problem introducing this idiom (or similar). In fact, I = welcome it. >>=20 >> In userland, the same concept is often achieved with methods like=20 >> `fromOrNull()`, and as Mark points out, the word =E2=80=9Ctry=E2=80=9D = makes me think=20 >> the method should throw an exception if it fails. I=E2=80=99m not = advocating=20 >> for `xOrNull()`, though, since I think that smacks of Hungarian=20 >> notation, but maybe we can come up with something that is a more=20 >> PHP-ish name. ;-) >>=20 >> =E2=80=9CThere are two hard things in computer science: cache = invalidation,=20 >> naming things, and off-by-one errors.=E2=80=9D --Phil Karlton >>=20 >> Cheers, >> Ben >=20 > Do you have a suggestion for a better, more PHP-ish naming convention? maybeFrom()? >=20 > "It's what other languages use and they don't have a problem" is a = valid argument, but not a slam dunk so alternate naming patterns are on = the table. >=20 > --Larry Garfield >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php = --Apple-Mail=_8F78F7CE-18A6-4A2E-9DB9-203C197E789D--