Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102830 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22340 invoked from network); 15 Jul 2018 16:31:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2018 16:31:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.221.67 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.221.67 mail-wr1-f67.google.com Received: from [209.85.221.67] ([209.85.221.67:43734] helo=mail-wr1-f67.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/B2-39793-6D67B4B5 for ; Sun, 15 Jul 2018 12:31:18 -0400 Received: by mail-wr1-f67.google.com with SMTP id b15-v6so29581918wrv.10 for ; Sun, 15 Jul 2018 09:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:cc:from:message-id; bh=HGjYYnZI5sQlAv0oRlaLNmle1R5bdQy9X861/xRP0WE=; b=BpalyBPL1JSrsCVraOwMDsXevedQpFjaGi+snwR/2/ZvuQ1A7rouGrxfM9hi8jjZ9Y 0453t6E/UNGHDsfOuvsY0x0/DHCitHz0hzKxQMGCg7ysNC4aKpsDw0u8pNzO/OYKfHV9 phIMbyzzjDwEY1B2lMuPp3XohhGtg9ddHSD00Jhfi3EI2UJV7KUL4EucdIn+oDCLT8ho 7J9UrkPvPzrT0NIuIgHIPRfNv1TVhB6f0yvhhI9IkIWtQxa5Fx/CetrtFbZIod4oskFG nt5AwYI3erscSjO6xdoHB9gcfURvQGTdo23/+0svUU5vf0KRG5j7xsAw4JD+HRhIG2y6 /OZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:cc:from:message-id; bh=HGjYYnZI5sQlAv0oRlaLNmle1R5bdQy9X861/xRP0WE=; b=BD/KMgjFai2FWIv14BTK2YBncpcWLYE5FegX1xfroPsoUU0McTeW5h8AhLLY0FguuS yYRSu94GAw04tq1s4ozHLTMakApF5W8X9T6Lcxr40aT3vKE2DtbRRVC9A0WxCAMMAn9F 3ZtH2482kKrcwyX6NiuBFJDCbcL4cdLQzXzof0UOKrDrpKqBtfftMaXfJi7p6ruWlMVz DBpoyKQUi8xEkJIL0Zr/Jxq0Ap78NCWj9PnnqqhhpCmDvRjMaGWbYigvo1BDjRxDqHIB v8OkulKxY3Ub1GKmILF6RjS/IbRfYAKcSWRTC7Vwc++zlR6LUg28R/YONQ36gBn0Yyji tccA== X-Gm-Message-State: AOUpUlFHs9raiFpaF1AGoQ1N+xWpFu5nc2oyZdC0EkA18GoGEWVkGf1g FIcHiMPySGQWyxd22WxQkjNCETHX X-Google-Smtp-Source: AAOMgpfFDMMNzt1Smj36jv21MbKTPKhsIEtKmoPphsSai00t2JcHiyWr9NkuFc59Rn00O6NMsRz6OQ== X-Received: by 2002:adf:8103:: with SMTP id 3-v6mr9444173wrm.213.1531672274798; Sun, 15 Jul 2018 09:31:14 -0700 (PDT) Received: from [10.177.84.172] (92.40.249.185.threembb.co.uk. [92.40.249.185]) by smtp.gmail.com with ESMTPSA id b198-v6sm14586902wme.11.2018.07.15.09.31.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 15 Jul 2018 09:31:13 -0700 (PDT) Date: Sun, 15 Jul 2018 17:31:10 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: <8916EC21-D368-40F8-9ABD-CE0C04A73539@gmail.com> <6E843F96-7815-4525-8AB1-D9D700B0D031@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable CC: internals Message-ID: Subject: Re: [PHP-DEV] Non-nullable properties From: rowan.collins@gmail.com (Rowan Collins) On 14 July 2018 19:29:23 BST, Levi Morrison wrote: >Whether it's a constructor, a factory method, or just a block of code >near the `new` site: something has the responsibility for >initialization=2E Indeed, and my suggestion is to formalise that responsibility, so that mis= takes can be detected closer to their source - which is, after all, the who= le point of type constraints=2E > Once initialized the object provides guarantees unless >you `unset` the property=2E But since you have no way of knowing if it was initialized or not, this is= n't a guarantee you can actually base code on=2E > It also provides the guarantee that if it is >set then it will always be of the outlined type; this is a much >stronger guarantee than we have today, which is=2E=2E=2E nothing=2E I'm not saying we should block the whole feature (apologies if that wasn't= clear), so that's not the appropriate comparison=2E The comparison I'm int= erested in is between writing=2E=2E=2E /** * Will be initialised in the constructor and should not be unset=2E */ public Foo $foo; =2E=2E=2E and =2E=2E=2E /** * Will be initialised in the constructor and should not be set to null=2E */ public ?Foo $foo=3Dnull; In both cases, the intent is documented, but not enforced=2E If we allow the first version, with no actual checks on the initialisation= , it will be very hard to introduce a stricter version later=2E If we only = allow the second version in the initial implementation, we lose very little= =2E The rule could be very simple: typed properties must specify a valid defau= lt value=2E That means object hints will have to be nullable, with a defaul= t of null, and there is no need to invent a new kind of "null reference"=2E Regards, --=20 Rowan Collins [IMSoP]