Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107316 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93444 invoked from network); 24 Sep 2019 19:45:33 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 24 Sep 2019 19:45:33 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 205A52C0464 for ; Tue, 24 Sep 2019 10:24:30 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: No Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Tue, 24 Sep 2019 10:24:29 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id t3so2532127edw.13 for ; Tue, 24 Sep 2019 10:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5oqIA9sPtltpv2iOFDnpNokJB6qZN16huhIHwjhrhV0=; b=S5XkbFuREILc/hCVIQh2UW/0T8YP2seSbae5kVypNVfTZjQ6eMkSqmonO3EIULlXMq T8zChwlwZhqL+Xo2x0ufCZSx6y/7sQTJxeijUYOcKAY7CLnoatoGEzBz2D9C7I07vx3M 9ZX/5jQx34HVRfE73wlkpSi7+gPAHVSXur6TfJWK8w277bzIPaVbdvW14fGMvkcgwP/1 Ziw7CQeevakPy+rjFgJhlokSbRjziSeq6yBqXjCzpjqmcLG6hoZu8wXFu4asU3IJzE4b FKpe/GatPFiY+fwvOXSs50nCsJUYXZrdFUry6hPhiiM2LPnnalKQHQd2KMxRZBcSdZ5n Htyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=5oqIA9sPtltpv2iOFDnpNokJB6qZN16huhIHwjhrhV0=; b=O7vtUTmlXZ3aLx3kU/r+MDC0ahisfv6e0M1YcDLMD0Gbl1+V7RHGjLfO0ER4K90LMZ 6XHNuhajUWTKp843VlimjrF6MgBnn5M3rYzZl9ZJ/igu1zeOT4m4d83nTAA/Kd+13W8p 1JgylY1oRGb9tyEP7uha5hbRHDxX1X91O2v6vdZCGkUXV2NZjG1l1kwowcfVtHa938aZ nUwr79H4WMgFuLdhPWKdH2WjzoR/zLHXzrVkwGpctSQMoswc2O3k1JVm1BgPVx8m8VGQ 7l+GRzRCUkrZxRCzPvzn6UfNSV1X1kA+76AKir897ecLU5Oej8vXqVlpDSJokJD86y/Q +wcw== X-Gm-Message-State: APjAAAXhMDnXE4MdoL1uMQeQgixQcrvWmfoyXw/zDsVSqMmVfOv7j9MA GhFBigvxp20UnaL+JY6iOZ0= X-Google-Smtp-Source: APXvYqw81+tqvigGLlfM3fl9zkD72WBW/+sJe4qC3Gy/b/cfMrNBPCurK3S/IQ61uRkUl05V0uKn4Q== X-Received: by 2002:a17:906:5644:: with SMTP id v4mr3538683ejr.52.1569345868450; Tue, 24 Sep 2019 10:24:28 -0700 (PDT) Received: from [192.168.0.63] (84-75-30-51.dclient.hispeed.ch. [84.75.30.51]) by smtp.gmail.com with ESMTPSA id c1sm473221edd.21.2019.09.24.10.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Sep 2019 10:24:27 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Tue, 24 Sep 2019 19:24:26 +0200 Cc: Nikita Popov , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <1544E25D-630F-4E02-BCF1-1A0DEF1EBD60@gmail.com> References: To: Benjamin Morel X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Union Types v2 From: claude.pache@gmail.com (Claude Pache) > Le 23 sept. 2019 =C3=A0 22:14, Benjamin Morel = a =C3=A9crit : >=20 >=20 > So although true as a type does not have the same historical = background as > false, it does seem that it's being used by enough packages to be = worth > considering; what do you think? >=20 Considering to support `true` will raise several questions. They can be = resolved, of course, but that will put more design decisions over the = shoulders of the Union Types RFC: * The first one, of course, is why the list of possible literal values = is *still* restricted. Because now you=E2=80=99ll want to use other = literal values, e.g., `0` or `"some-string"`. * Another issue is the relation between `Foo | false | true` and `Foo | = bool`: whether the first form is allowed; whether they are equivalent = w.r.t. variance rules; how casting to `true | false` works (or doesn=E2=80= =99t work) under `declare(strict_types=3D0)`. * Also, if we support more than two literal values as types (and = especially when not all of them indicate failure), we=E2=80=99ll want = more strongly to have them to appear as standalone types, e.g., `true | = null`; and then, naturally, just `true` and just `null`. At this point, = the question will be raised whether it is desirable to have both `null` = and `void` as return types. ------------- The choice of supporting precisely the two literal values `null` and = `false` is not arbitrary: They are the two values that are the most = often used as sentinel values (for indicating failure or absence). It is = true that `true` is also sometimes used as sentinel value (more rarely = and not among the internal functions), but the same can be said of other = literal values (one of your examples includes `0`). =E2=80=94Claude