Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103197 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6267 invoked from network); 20 Sep 2018 14:51:47 -0000 Received: from unknown (HELO mail-it0-f50.google.com) (209.85.214.50) by pb1.pair.com with SMTP; 20 Sep 2018 14:51:47 -0000 Received: by mail-it0-f50.google.com with SMTP id p129-v6so11721883ite.3 for ; Thu, 20 Sep 2018 03:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QAPdF8BxAILJDpmZIIWf0rbVgPzL4cZZi6DwZefdYB8=; b=cq0RXVIqaomxBHqWY+iwOVJzGSf8OPqKK4QjMRkRIrscg18O6SK5+IvVnbYUkTgDmE 6meLv9giuxTQPjua+BsiWyVkM8mBI4VcLBbuayHiWvdtdp2irCn3WTSxLic4Ezj6m2iS XwKy8kKd/swzQmEdbDzeXJLz+h2EGwfKw8JYZJnjF2a4oMeYEcvYUeMYDVMgUXbmRsj6 Ki2XFIjr56SMxCpF4T5NAzwaaHvVkLJKNtBLbrV+wXX6a5Robuh6+NkjmyCt323J0B5D WpRxoREzULTLWUk8REFJsO1D5XkGNN9JE3/JqKlVJcLJn0RdLMcLak85Hm1j2QeEcVBM allw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QAPdF8BxAILJDpmZIIWf0rbVgPzL4cZZi6DwZefdYB8=; b=TSOOohB6vB37Z4j+u5WG2ttOhGdD6mnQHaPG+nVfZom4q7EqoubX9Rw3VDCZSfjTEU 4gF3BalqULvJQOeWNoNkgouP/uORmQqtGc8dZtvldGZM/2mCbTaQJX+q9JyHIaXNacY3 canJc24prw0td8newvI/DTXVcSdOSGdWQN4sBcVTHEfQMVAN1Gcd/HsespjAPOVBW4i/ iMSBmK9wDNKnydpZYjV5VDb2S7LPulLDAC7TDiAM2RFEdfzsO9P+H/P6yDH6ZYyJAgyi J3IiPKZ3bb2LlYsH8RMbXuVe0AyU3EOEKnDsEYpLuZSMdUW1GJn66i/36DQhKh8o1c3E Z3nA== X-Gm-Message-State: APzg51BvGG8kyWb/Rje9kgGnnHsJP4HY85DHuPkQb8b0aJJD3BX6QMcL qiBVps4HaG0u5qbw74b5cQAXiuMkBkOIIYahWmg= X-Google-Smtp-Source: ANB0VdbeQn/j/pKbWE8Yax5OlN3K9Rk7n++QzVpSEhDCMcj2orrL829x6gv6m7VU4ktR4rUSoWFN2QEF1TmlRXOm2+A= X-Received: by 2002:a24:c303:: with SMTP id s3-v6mr1470976itg.10.1537441102773; Thu, 20 Sep 2018 03:58:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 20 Sep 2018 12:58:09 +0200 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000cb434805764b66f8" Subject: Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2 From: nikita.ppv@gmail.com (Nikita Popov) --000000000000cb434805764b66f8 Content-Type: text/plain; charset="UTF-8" On Wed, Sep 19, 2018 at 2:38 PM Rowan Collins wrote: > On Tue, 11 Sep 2018 at 08:05, Bob Weinand wrote: > > > Hey, > > > > As announced, we are starting the vote on typed properties today. > > > > The voting period is two weeks, until sometime in the evening on Tuesday > > 25-09-2018. > > > > Please find the RFC at https://wiki.php.net/rfc/typed_properties_v2. > > > > > For the record, I still think we will come to regret allowing non-nullable > type hints without any constraint on the author of the class to initialise > them correctly. As proposed, the invalid state may only be detected when it > causes a runtime error in completely unrelated code. > > I gather that the authors of C# are currently going through a painful > development phase to introduce better support for non-nullable types, and > having to include many compromises and handle many edge-cases because it > was not done earlier. I realise this case is not completely comparable, but > we have an opportunity to get this right first time, and not just take the > easy option. > > I am therefore going to make one last plea: if we don't yet know how to > assert that complex types are initialised, do not allow them to be > non-nullable in the first version of this feature. > > That is, allow `class Foo { public ?Foo $foo = null; }`, but not `class Foo > { public Foo $foo; }`. > > This would still be a huge improvement to the language, but leaves us free > to design additional features to prevent Unitialized Property Errors > becoming as hated as Null Pointer Exceptions in Java or C#. I am sympathetic to the wish of reporting initialization errors during construction rather than at the use-site. However, there is no clear proposal on how this will be reconciled with other requirements that we have, such as support of uninitialized properties for lazy initialization, etc. I do not consider it advisable to require a null initialization as a "first iteration" of the proposal. Regardless of what our intention might be, the effect of such a restriction will not be "I'm not going to type this property for now, because non-nullable types are not supported", it's going to be "I'll give this a nullable type even though it isn't, because that's better than no type at all." Use of nullable types where they are not necessary would be a disastrous outcome of this proposal. To move this discussion forward in a productive direction, we need a concrete, detailed proposal of how enforcement of initialization should work, while being compatible with secondary requirements. I believe it goes without saying that we cannot change the typed properties RFC in such a substantive way at this point in time. However, if you or someone else can bring forward an RFC that specifies the precise semantics of initialization checks as you envision them and which is endorsed by maintainers of libraries with special initialization requirements, then we still have a lot of time to discuss and incorporate such a proposal before typed properties ship in PHP 7.4. Thanks, Nikita --000000000000cb434805764b66f8--