Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92395 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73643 invoked from network); 18 Apr 2016 05:23:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2016 05:23:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=marcio.web2@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marcio.web2@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.44 as permitted sender) X-PHP-List-Original-Sender: marcio.web2@gmail.com X-Host-Fingerprint: 209.85.218.44 mail-oi0-f44.google.com Received: from [209.85.218.44] ([209.85.218.44:34837] helo=mail-oi0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/80-32052-F3F64175 for ; Mon, 18 Apr 2016 01:23:11 -0400 Received: by mail-oi0-f44.google.com with SMTP id p188so177479179oih.2 for ; Sun, 17 Apr 2016 22:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2sJBUFKR0RtZEhvx8AX00XDhHHNJt8pID3mcjb7l+1s=; b=PXRjHJ/j4YoXjnBAmB5HYeQNpW8t2wneHseNnm7/W7y/WmApxpchkarwI/W0evdZxP KQmCCLmi+VoGNsKF774HqloBUHwkm6BszRwkJ2vSZ90zZFBCrp250bzrZt1qVm76OZrt ZGsivIE/xUisTGK4I2KNG6UDAecVJuwJtl6T5innObhIcEo6vF/1WvV4DnFiToDQySyP KdypTfyquQ1chVkloPqC/yOPFMiaMbiCqq7/FrGodjSYlT+FwlboPaGT9r/AmhSgs35l utki6CyT5FGEsjrbiEtxnT7vKyS4VxYHCuXOtOtGJ2hWKZBASSwfBOGTKms4Iwe7ex0b qfKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2sJBUFKR0RtZEhvx8AX00XDhHHNJt8pID3mcjb7l+1s=; b=MxqwX7KeqasT55/EVEr+B6lHnhVxreF1Eh9LrmQaEPjE0LOctjkLzXA4Ii5EcBNJgK ja+1elZY/5Z3InJQyD138M5AeGM8WaK7+ZXb++6WFqSwFqSU/4+mo7ay96J6fnCdNb1L vIto41uSy1s0X4SXiHe3LSdLqMAweNNFi/aChPDRtOR+kubBA+s9N7UclPgPT/YyDdAT t1Onn70pF0SgSPYybQLf6JVN2URvtm1nQIuaaTochFW+52X6GHThVnmyY6oGydF0GdE5 NN5mhuJxm7V5Eq3nIFG3jWIJFFciH+0q15m2K5fs9MD/GQZ5W7gKioOmbJaoHYcaAuag KLaw== X-Gm-Message-State: AOPr4FWZm5mhnhDSrpAdoR3OPkiVbOseHswOAgCQ7E9PjBJqp0TDlnSSogAJzfonA4g1h/945NtR4mG5CrtvmQ== X-Received: by 10.157.4.23 with SMTP id 23mr14600323otc.190.1460956988879; Sun, 17 Apr 2016 22:23:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.192.198 with HTTP; Sun, 17 Apr 2016 22:22:49 -0700 (PDT) In-Reply-To: <57145AF7.7060607@garfieldtech.com> References: <57103A46.6040803@garfieldtech.com> <5710BA79.5060108@lsces.co.uk> <57110DC5.8000007@garfieldtech.com> <571338E6.50507@fleshgrinder.com> <57145AF7.7060607@garfieldtech.com> Date: Mon, 18 Apr 2016 01:22:49 -0400 Message-ID: To: Larry Garfield Cc: PHP internals Content-Type: multipart/alternative; boundary=001a113be13e5abbd20530bb8eb2 Subject: Re: [PHP-DEV] [RFC] Nullable Return Type Declaration From: marcio.web2@gmail.com (Marcio Almada) --001a113be13e5abbd20530bb8eb2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi! 2016-04-17 23:56 GMT-04:00 Larry Garfield : > On 04/17/2016 02:19 AM, Fleshgrinder wrote: > >> Everything always has pros and cons and I do not think that there is one >> answer to all of these questions. Different languages handle this >> problem differently. PHP has `NULL` and we should keep it this way. To >> minimize bugs resulting from unchecked `NULL` usage a compiler feature >> could be implemented that warns a developer in such cases. We already >> have it for uncatched exceptions (although IDEs are currently not >> telling one about that; Eclipse does in Java though). >> > > Rather than debate the relative merits of Null as a concept, since I thin= k > all agree removing Null from the language is not even a thing, what do yo= u > think of my recommendation to NOT have the ? shorthand for "or null" on > types, but keep the |null for union types? That is, if you want to retur= n > Foo or null, you have to use the long-hand version: > > function foo($a) : Foo|null > > That > > 1) Allows for explicit or-null behavior. > 2) Doesn't make it quite so easy, which hopefully discourages (but does > not prohibit) its usage. > 3) Neatly avoids the ?Foo / Foo? question entirely. > > I think that's a win-win arrangement. > > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > I can agree with that. Language design wise, if you have no way to forecast how language features independently proposed are going to interact then it's a good idea to have a converging strategy. Fortunately, this seems to be happening almost spontaneously towards union types representation, as in the "multiple catch" RFC (https://wiki.php.net/rfc/multiple-catch) now in voting phase. Even if we decide not to commit to a full union types implementation now, the design process will be much easier in the future if we decide to use Foo|null instead of Foo? or ?Foo and we will not end up with 2 or 3 ways alternative to declare the same thing. Cheers, M=C3=A1rcio --001a113be13e5abbd20530bb8eb2--