Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93505 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82156 invoked from network); 25 May 2016 14:47:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2016 14:47:25 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.219 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.219 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.219] ([81.169.146.219:50660] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/50-14311-BFAB5475 for ; Wed, 25 May 2016 10:47:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1464187641; l=6985; s=domk; d=kelunik.com; h=Content-Type:Cc:To:From:Subject:Date:References:In-Reply-To: MIME-Version; bh=ioQZfv4p5TEvLaeFHmTuW5JDTSLyr+M9mQGVGs94dso=; b=VaieIn4PHlvIEOkRjUBvFx5AD4uSQafAmV+Juq4O/XyHCJv6LouUFwRR7RfgdfJLPRy BIJgu60LWScbdJ5WWTs/aFOl3eKWR6WEICO2O3hs7U+YP7Vm01CAVLWHlNN91p260+pZm opEcVqfmBAJe1Hz8+gKU2SUy41pvSJg3F/o= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtO3o6 X-RZG-CLASS-ID: mo00 Received: from mail-wm0-f49.google.com ([74.125.82.49]) by smtp.strato.de (RZmta 37.27 AUTH) with ESMTPSA id n003d8s4PElKqVv (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Wed, 25 May 2016 16:47:20 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id a136so130024777wme.0 for ; Wed, 25 May 2016 07:47:20 -0700 (PDT) X-Gm-Message-State: ALyK8tLiAtxM9wOYj/RFwxl+NlmrA6cDhG+qREdw4MhFsE5bY3SJHTUUzJ3GYNY6oYqNDeRWv5eLIs+3g59mYw== MIME-Version: 1.0 X-Received: by 10.28.27.81 with SMTP id b78mr4007950wmb.19.1464187639954; Wed, 25 May 2016 07:47:19 -0700 (PDT) Received: by 10.28.53.132 with HTTP; Wed, 25 May 2016 07:47:19 -0700 (PDT) In-Reply-To: References: Date: Wed, 25 May 2016 16:47:19 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Nikita Popov Cc: Joe Watkins , Dmitry Stogov , PHP internals , Phil Sturgeon , Bob Weinand Content-Type: multipart/alternative; boundary=001a114b9fd42a0c460533abc091 Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: me@kelunik.com (Niklas Keller) --001a114b9fd42a0c460533abc091 Content-Type: text/plain; charset=UTF-8 > > On Wed, May 25, 2016 at 10:30 AM, Joe Watkins > wrote: > > > Morning Dmitry, > > > > > I made this check(s) to be invariant. You may like to do this > > differently... > > > > I think this is what everyone expects, isn't it ? > > > > I did omit to mention that part ... > > > > > RFC doesn't define how uninitialized nullable typed properties > should > > behave. > > > > It does: > > > > > *Nullable typed properties will not raise an exception when accessed > > before initialization.* > > > > I don't agree with this choice, for three reasons: > > a) This unnecessarily restricts what can be expressed in the type system. > With these semantics it will no longer be possible to express that a > property should be nullable, but have no default value. This situation is > not uncommon in practice, in particular anytime you have a nullable > constructor argument, you will want the corresponding property to be > nullable without a default, to ensure that it is explicitly initialized. > I disagree here. Properties are always null by default. The current patch disallows access to uninitialized variables only if they're not nullable, since null isn't a valid value then. I don't think having to explicitly set them to null is the think we want. And it's not what I'd expect given the current system. > b) This directly contradicts the meaning of ?Type for parameters. For > parameters ?Type means that it's a nullable parameter **without a default > value**. That's the very thing that distinguishes it from the Type $prop = > null syntax. And now ?Type for properties should mean the exact opposite? > These have always been different. `private $foo` has always been `null` by default, while `function($foo)` doesn't have a default value. > c) If you view this in a larger scope of union types, this *special case* > becomes even more weird. Why does the particular union Type|null get > special treatment, while all other unions don't? Or is it actually not > specific to "null", but to single value types? E.g. if we also allowed > Type|false, would that also receive an implicit false default value? What > about the type null|false? Does that get an implicit default, and if so, > which? I realize this is not quite in scope for type properties, but the > further evolution of the type system should be kept in mind. > I think this is something unions should address. I'm personally still not a fan of union types, as they try to solve the wrong problem, mostly things like array not being instance of Traversable. Regards, Niklas > Please keep things consistent: If there is not default, there is no > default. > > Nikita > --001a114b9fd42a0c460533abc091--