Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74115 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32921 invoked from network); 10 May 2014 09:24:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 May 2014 09:24:59 -0000 Authentication-Results: pb1.pair.com header.from=php@marc-bennewitz.de; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@marc-bennewitz.de; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain marc-bennewitz.de does not designate 80.237.132.171 as permitted sender) X-PHP-List-Original-Sender: php@marc-bennewitz.de X-Host-Fingerprint: 80.237.132.171 wp164.webpack.hosteurope.de Received: from [80.237.132.171] ([80.237.132.171:32936] helo=wp164.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/0E-46741-A60FD635 for ; Sat, 10 May 2014 05:24:58 -0400 Received: from dslc-082-082-191-161.pools.arcor-ip.net ([82.82.191.161] helo=[192.168.178.27]); authenticated by wp164.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) id 1Wj3WZ-0006LU-0S; Sat, 10 May 2014 11:24:55 +0200 Message-ID: <536DF058.8010904@marc-bennewitz.de> Date: Sat, 10 May 2014 11:24:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: internals@lists.php.net References: <90B71511-4FB4-4916-9AC0-E3DD0D328C37@fb.com> In-Reply-To: <90B71511-4FB4-4916-9AC0-E3DD0D328C37@fb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-bounce-key: webpack.hosteurope.de;php@marc-bennewitz.de;1399713898;6e242e34; Subject: Re: [PHP-DEV] [RFC] Return Type Declarations pre-vote follow-up From: php@marc-bennewitz.de (Marc Bennewitz) On 09.05.2014 22:06, Josh Watzman wrote: > On May 9, 2014, at 8:09 AM, Levi Morrison wrote: > > First minor issue: you have a return type "self". This is an LSB type, effectively the type of "new static". Levi, I remember discussing this with you in IRC, but not the result of that discussion. What is the reason for "self"? The Hack type system calls it "this", which I admit is a little confusing since it is the type of more things than just the literal variable "$this" ("new static" for example is also of type "this"). But the type "static" is much more consistent with the existing LSB language, i.e., "new static".. So is there any reason to call it "self" over "static" or "this"? The keyword "self" should be a valid return type and simply alias the current class. The keyword "static" should be a valid return type and simply alias last class of the list of inheritance. Example 1: (fluent interface) class Fluent { protected $property; public function setProperty($val) : static { $this->property = $val; return $this; } } Example 2: (extendable singleton) class Singleton { protected static $inst; public static function getInstance() : static { static::$inst = static::$inst ?: new static(); return static::$inst; } } "this" isn't a keyword and from reading perspective it is pointing to a variable $this but $this is a object instance and not a type. The type of the $this object is the same class "static" is pointing to as shown in the fluent interface example. > > Thanks for putting this together -- the FB team is really looking forward to it. > Josh Watzman > > Marc