Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92546 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51993 invoked from network); 20 Apr 2016 15:06:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Apr 2016 15:06:20 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.175 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.223.175 mail-io0-f175.google.com Received: from [209.85.223.175] ([209.85.223.175:36175] helo=mail-io0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/1C-14036-CEA97175 for ; Wed, 20 Apr 2016 11:06:20 -0400 Received: by mail-io0-f175.google.com with SMTP id u185so55152167iod.3 for ; Wed, 20 Apr 2016 08:06:20 -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=bC3EzMrGaz9DGmOkFY7vbCudWyNPlnct4cQbnWeQiuk=; b=OPDn+ZsUqsu9Yrf/IZOZ4LNC7gz4tzaMIvmB2sy7EhUor+pw3BOT3hddPw7yMufaHn H+0FyrxHaPhguIhUeojCsGS8mYV5lEdBy5s+zMVLz76Eh8J5ArhX+wfwU/ydqSf+uje5 iyhAdoRzNH4evuLpNDKX3LmG59NqfK1bhZ9Da522K+EOuNwzyykTFWPjG8pNnysKCki+ dTGiUUyWbjXs7hIsdNnuStTh9hG7Br949sxs5C3oxE3UVD3oGwBOb3SSd0aCyCkP0dBQ OTM8ly1ZAeCfFvTSzd0PPGdN6edDwyVx6K9Z1fx8uES/Tee4Bgj31xPO2gT17RkjbSQC W5EA== 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=bC3EzMrGaz9DGmOkFY7vbCudWyNPlnct4cQbnWeQiuk=; b=IkIn4G9TwJFEfLin67iEXlLHjd1NIBzOf87Dv+lzmXij4nrblXSVDWaNM1SanUMTl8 Of8ZFMYqZ8eZI1Q5vIoBBlMal5TlWHUdzIary87Uauwq4ugdqX2hsDGf3iEELCvguPZy zjMCqryoJZiZU7C8RorbIoYlBmKpkIPWYc1A6y8nj6gcxKhCI0V6lD63AeY/QfqUvbxG fi4DyY6vsmwUWJqHxbeYEnAlPHnU1oCPg84e3cjvcegYph+TlHn85Ou5topcYU6GVAwi G11eesoRNMojVgF1BX4N6QYrERKNs+RUoiVCacW3H/jJvzf+BXxCwECGuXpMRE5WjgXx P/rg== X-Gm-Message-State: AOPr4FWXqZCftobUFNB2qa1rkd6gacv9uSwBgpx/5CTRvjeamIZBCfW2AkKJq6v2h26Pk2jYUx6fF8fU1bKyBQ== X-Received: by 10.107.31.129 with SMTP id f123mr10780896iof.180.1461164777798; Wed, 20 Apr 2016 08:06:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.85.10 with HTTP; Wed, 20 Apr 2016 08:05:58 -0700 (PDT) In-Reply-To: References: <570F4BB4.6020709@zend.com> <57112225.6020905@thefsb.org> <57119B5E.6070205@thefsb.org> Date: Wed, 20 Apr 2016 11:05:58 -0400 Message-ID: To: Lin Yo-An Cc: Dmitry Stogov , Tom Worster , internals Content-Type: multipart/alternative; boundary=001a114026de8a00e60530ebef96 Subject: Re: [PHP-DEV] [RFC] Nullable Types From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --001a114026de8a00e60530ebef96 Content-Type: text/plain; charset=UTF-8 I read the RFC and I want to highlight why I'll vote -1 on it even before it goes to voting. IMHO, it looks backwards to what the language is progressing. The introduction of nullable type hint as a separate notation than a simple type hint makes it *very* hard to implement typed properties, factory methods and constructor verifications. Dmitry is even involved in the discussion of having IS_UNDEF until constructor ends, then enforcing type hinting at the end of constructor to trigger potential invalid instance state. It created a mess in the internal structure by creating a 3-state value: uninitialized, absent of value (null) and assigned value. All this problem would be solved by merging null into accepted value. So far the proposed solution there to take a wrong assumption to assume a default value based on type defined (like int = 0, string = '', etc), which are all potential valid values, leading to unpredictable behavior if a develop misses to assign a value to that property. Sure, people will say that now PHP will require a NullPointerException, PHP is turning into Java, or that I don't know what I'm talking about because they coded for Amiga and I don't (yes, I've seen that already in this mailing list). But the fact is that keeping control of 3-state flags are hard to maintain. Constructor verifications is actually a completely different subject that shouldn't be considered as part of typed properties, but for final properties (or whoever other keyword someone think is smarter because *reasons*). It's bad to bring this already to typed properties, specially because of its runtime performance impact. Now let's say we move forward with nullable type hint, ignore everything what I said and move forward. Congratulations, we just created a language inconsistency. Example: function foo(Bar $bar = null); Why now I have 2 ways to define a nullable value? Shouldn't this be changed into this: function foo(?Bar $bar); But of course, changing this would be a BC break and should be left for *reasons*. But accepting the absence of value (null) as a valid value, it would address the language inconsistency (the current support would be kept, so no BC break), and would solve a huge mess that typed properties patch currently needs to solve. Ah, and we don't continue into this path of madness where same thing have 144 different ways in different areas to be defined. Regards, On Mon, Apr 18, 2016 at 12:24 PM, Lin Yo-An wrote: > On Mon, Apr 18, 2016 at 4:59 PM, Dmitry Stogov wrote: > > > The grammar is taken from HHVM. > > Using any other would make more mess. > > > I agree > -- Guilherme Blanco Lead Architect at E-Block --001a114026de8a00e60530ebef96--