Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92706 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83048 invoked from network); 25 Apr 2016 06:18:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2016 06:18:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=jesseschalken@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jesseschalken@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: jesseschalken@gmail.com X-Host-Fingerprint: 209.85.223.170 mail-io0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:35462] helo=mail-io0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/3A-13951-FC6BD175 for ; Mon, 25 Apr 2016 02:18:55 -0400 Received: by mail-io0-f170.google.com with SMTP id d62so71865669iof.2 for ; Sun, 24 Apr 2016 23:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=Qsl9VHV5LS2Yr/oVmKefzBZaMrbPNUhRmCK7UjMk7f4=; b=rY1PbNE9gGiaFxkf+cm5noXYM1UFoYhh7h7fP6qb4RdfQhKPTmdiHOrlqq01sOjvhe 4mFybZ3+jEY+yurbtAH1Dn5bJEJqRYhaLQQ7NoXag0LLijc2Hs7ZCc717K9IsSn2E+/a E5qLqqqVbbUKw2jOFIDZCodou5xWr0ww/2SiD/ZHcnO40bnxtvTZiD39A4v2iIE+kbOe itLnOEyJPToYECqWi3wpR/DPX8pn4RZqppUxFHiMZxjH7bPH38Ak03+/Ve0MfHKjgxYn K5tMpzTX8aUcWFlP08b0S4M8E3BP6hRl/V1IYqVRSHewticoPTj51pJVyMkuCC1T7yuN MYZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=Qsl9VHV5LS2Yr/oVmKefzBZaMrbPNUhRmCK7UjMk7f4=; b=XIWJGKLJica6ocixTJbfRUCdpje6TakPDRINxgzfIXqw8ygiq4R1tI7vkiDy5u908t cYqkxDJaGlP7xd/w9YKQQHtVCkuWji8D8SDaUZuw6m8XosNoR5TCXHXeUVU3odeOV5Z/ vdLjY0pgA9jDl7TLmRzJKVN1+q+8IQ8nQMw5C9AdckFejq+41B8j0ok/OBL1owcwpzj4 SkDOcsyj9w82X6dLtJa6t9C0RVHp+8u7rRJ1o8kBAjQk2e5gDYHCOP2HC7q2ECY3RsuB nlLbNE1k/wTKhs4EdKqB8q9X4o2h7o0iEMTkjxwmNEQiAFJ0aCdpxM59+JhEZHkEj8oh yrOQ== X-Gm-Message-State: AOPr4FW8yg4LQNmLEyiXTigmfCsmatHtgQaAZc2UkYQ27mncU18d8z9+lGIPRAk+wtwHiI9gPvOwZxRBwpYsdw== MIME-Version: 1.0 X-Received: by 10.107.137.166 with SMTP id t38mr8038000ioi.31.1461565132947; Sun, 24 Apr 2016 23:18:52 -0700 (PDT) Sender: jesseschalken@gmail.com Received: by 10.79.139.133 with HTTP; Sun, 24 Apr 2016 23:18:52 -0700 (PDT) In-Reply-To: References: <57192F87.4080902@fleshgrinder.com> <571B6AF6.5030001@fleshgrinder.com> Date: Mon, 25 Apr 2016 16:18:52 +1000 X-Google-Sender-Auth: YiMc6wG74sHt5StPb0IHoWQO5cQ Message-ID: To: Levi Morrison Cc: Quim Calpe , PHP internals Content-Type: multipart/alternative; boundary=001a113ebd8090d705053149261c Subject: Re: [PHP-DEV] [RFC] Nullable Types From: me@jesseschalken.com (Jesse Schalken) --001a113ebd8090d705053149261c Content-Type: text/plain; charset=UTF-8 On Sun, Apr 24, 2016 at 2:58 AM, Levi Morrison wrote: > On Sat, Apr 23, 2016 at 10:40 AM, Quim Calpe wrote: > > Option is no better than a union type with null[1]. If a language > requires an option to be unwrapped then it can do the same with some > type or null. This is what Swift does. These things are exactly > equivalent. > I don't think that's strictly true. Option (or Maybe) types that must be unwrapped can usually be safely nested as Option>. This is important if you have a generic class Foo that uses Option internally and Foo is instantiated as Foo> (using string as an example), causing an Option> to occur inside Foo. If Option meant string|null, the Option> would become string|null|null and the real "null" at runtime would become ambiguous. Nonetheless, nesting is very rarely needed, but it is something to keep in mind when using generics in combination with union with null for nullability. > However in PHP we do not have generics, which means a nullable type is > actually better because we can express the type that participates with > null. With an Option type we cannot. > > [1] At least with the behaviors here. If Option is a Traverable that > returns 0 or 1 items then we can use that behavior to our advantage. > Of course, we lose the ability to express the underlying option type. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113ebd8090d705053149261c--