Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92010 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86235 invoked from network); 30 Mar 2016 07:50:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2016 07:50:29 -0000 Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.161.178 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.161.178 mail-yw0-f178.google.com Received: from [209.85.161.178] ([209.85.161.178:34162] helo=mail-yw0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/30-24137-4458BF65 for ; Wed, 30 Mar 2016 02:50:29 -0500 Received: by mail-yw0-f178.google.com with SMTP id h129so48625070ywb.1 for ; Wed, 30 Mar 2016 00:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pthreads-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=IZefLdyo85giAd/2DwGNkbIJprdE8gXA1WrwR4MCgMA=; b=14EY0Weexd9oDSBpa/Xw9kpaGAPfHFl0JMtXf1F5PIrQF/j+6gye3gjq7kdY601Yf5 L3rH39e/Oau8LLQekuTc3cz62DYwDYP6Clh3rjZzjTkrj7m6KVuMnm8XOUw5l3YbGTXb 0KANwybTn2Ww0UfbZEOiAsP3jIgHIctZuqgUIFq5CeBFv34jaWPbUhSuoHtz84j44g5E 9BEvXdtRDn9J9myNCMVsPI+SZbyVyXgHe0ImKXG1A77WquQbmTgrZvRidDxWa49k1RQB RvlANVoHDpDMq+k0OLg6M7uKCRMtkAgk9uNZdlJxSO303xVQ9ynqfyvb7ONTrD3w94+K w0xQ== 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:date :message-id:subject:from:to:cc; bh=IZefLdyo85giAd/2DwGNkbIJprdE8gXA1WrwR4MCgMA=; b=I0VeAdmw7hAJXJ6UjKJQwyA3AuPB0txaLT5MyURydihUOR663pHKI4tdBg3WRxZexC vyeDxDi2Gw0hhTs0qt4EZJ2whTWUFLHYQ/apTcWQRcx3MTcVTl1NFDLcLJ/mV7LN2pjA LkXOCOo/Ohpy1VqdnI3mbnZaQlZlx21SNrTsu6eAGPHaAu40xZdrvEySL+Rc5/dckRSh NJMzW220x+0519hxBINXZEl+MGfCJ1Jocx0eQfJe0HDE3ww/tFj/iQXhCRvsBVBVosXT 76muh6pkhbnmRwXHvC04TcD7kGYV6ubghlzoZpwQuqaaXh9UDDlwMo5XgRz6u+RfDmB0 M/og== X-Gm-Message-State: AD7BkJK4cEYuwUMmm7Roz6zVhlj9Yk9fk6yycXEl7UvrOk5xeEMo4JFQjO1UOZUXvsjeqO53U34z9HamRpWjPg== MIME-Version: 1.0 X-Received: by 10.129.73.195 with SMTP id w186mr291477ywa.273.1459324226200; Wed, 30 Mar 2016 00:50:26 -0700 (PDT) Received: by 10.129.39.9 with HTTP; Wed, 30 Mar 2016 00:50:25 -0700 (PDT) X-Originating-IP: [109.159.6.57] In-Reply-To: <56FB7096.9090602@zend.com> References: <56F14572.701@gmail.com> <56F15EF5.80006@telia.com> <56F16023.1010002@gmail.com> <56FB7096.9090602@zend.com> Date: Wed, 30 Mar 2016 08:50:25 +0100 Message-ID: To: Dmitry Stogov Cc: Pierre Joye , PHP internals , Philip Sturgeon , "krakjoe@php.net" Content-Type: multipart/alternative; boundary=001a114d32f01dc3c6052f3f66dd Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: pthreads@pthreads.org (Joe Watkins) --001a114d32f01dc3c6052f3f66dd Content-Type: text/plain; charset=UTF-8 Morning Dmitry, > If we use one rule for arguments, why should we invent others. Properties are going to be nullable only if you explicitly initialise them with NULL. We didn't really invent anything, you are comparing them to parameters, but not return values ... strangely ... Return values are not implicitly nullable, and a few people have been designing RFC's to tackle this issue by introducing expicitly nullable types, or union types. This code: class Foo { public function getBar() : int { return $this->bar; } private $bar; } $foo = new Foo(); var_dump($foo->getBar()); Should provide the same guarantees that this code does: class Foo { public int $bar; } $foo = new Foo(); var_dump($foo->bar); In either case, an exception will be raised. Given the following code: bar; } private $bar = null; } $foo = new Foo(); $foo->getBar(); We throw an exception, because null is not a valid int, and types are not implicitly nullable, even if parameters, and untyped properties are ... bar); Again, we raise an error, but much earlier this time ( we should all agree earlier is better). What we have done is apply existing rules in a way that makes sense, the only thing we invented is the rule that null is never a valid value. We invented that rule first to make return types and property types consistent, and, because without it, the guarantee that you will always get a variable of the correct type is gone, and your code is filled with null checks. There is value in nullable types, but they must only be explicitly nullable, in exactly the same way that return values should be, and we simply don't have syntax to support that at the moment. I hope this makes some of these decisions clearer ... Cheers Joe On Wed, Mar 30, 2016 at 7:22 AM, Dmitry Stogov wrote: > > > On 03/30/2016 08:13 AM, Joe Watkins wrote: > >> Morning Dmitry, >> >> So, I quickly reviewed the RFC and patch. >> >> Static properties, and mixed declarations, are now explained in the >> RFC. >> > Thanks. I'm not agree with decisions, but RFC is more complete now. > It would be great to have "static" typed properties at the same time, but > this may be more difficult. > Mixed declarations decision looks wrong to me, but right to some others. > From implementation point of view, it's not a big problem to change it. > > >> I made a couple of changes to the fetch_obj_w stuff, I'd be grateful >> if >> you could review that ... I didn't think I had got all possible >> combinations, should be bit better, and drier ... >> >> The overflow related stuff, I'll fix and explain in the RFC, but I'll >> let you have a go at perf stuff, and other outstanding things now ... >> >> */me leaves patch alone* >> > > OK. I'll try to do something today. > > Thanks. Dmitry. > > > >> Cheers >> Joe >> >> On Wed, Mar 30, 2016 at 5:26 AM, Joe Watkins >> wrote: >> >> Morning Pieere, Dmitry, all ... >>> >>> Actually it's not so simple ... for object properties we have ASSIGN_OBJ >>> opcode, but we don't have a special opcode for static properties, and >>> ASSIGN doesn't have any information about where the var came from, and >>> nor >>> should it have that information ... >>> >>> I'm going to stick the original decision, static properties don't belong >>> until typed variables are a thing ... >>> >>> Cheers >>> Joe >>> >>> On Wed, Mar 30, 2016 at 4:57 AM, Pierre Joye >>> wrote: >>> >>> On Mar 30, 2016 10:17 AM, "Joe Watkins" wrote: >>>> >>>>> Morning Dmitry, >>>>> >>>>> 1) static typed properties are prohibited. why? >>>>>> >>>>> Feels like that's a separate feature, static properties are as good as >>>>> makes no difference, global variables. >>>>> >>>>> Instance properties, the engine has good control over their >>>>> >>>> manipulation, >>>> >>>>> for static properties it doesn't, it's not impossible, but feels >>>>> >>>> separate. >>>> >>>> Internally different but from users perspective it is the same (a class >>>> property). It would be nice to support that at the same time to avoid >>>> confusion. >>>> >>>> >>> > --001a114d32f01dc3c6052f3f66dd--