Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74108 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60092 invoked from network); 9 May 2014 21:21:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2014 21:21:14 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.75 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.75 smtp75.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.75] ([108.166.43.75:49078] helo=smtp75.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/41-46741-8C64D635 for ; Fri, 09 May 2014 17:21:13 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 487EF1E8DD0; Fri, 9 May 2014 17:21:10 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp2.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id E51A11E8DC8; Fri, 9 May 2014 17:21:09 -0400 (EDT) Message-ID: <536D46C5.7040302@sugarcrm.com> Date: Fri, 09 May 2014 14:21:09 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Josh Watzman , Levi Morrison CC: internals References: <90B71511-4FB4-4916-9AC0-E3DD0D328C37@fb.com> In-Reply-To: <90B71511-4FB4-4916-9AC0-E3DD0D328C37@fb.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Return Type Declarations pre-vote follow-up From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > everything. This means that, not only can a superclass omit an > annotation that a subclass specifies, but a *subclass* can omit an > annotation that the superclass specifies. While this isn't the most I'm not sure it is a good idea. This means having this code: class FooGetter { function getFoo(): Foo { return new Foo(); } } I can extend it as: class TwoFaceFooGetter extends FooGetter { function getFoo() { return rand()%2?new Bar():new Foo(); } } and every function getting FooGetter and expecting getFoo() to return Foo is now broken since instead it could just get Bar(). Since the type return specification is meant, as far as I understand, exactly to avoid cases like that, I don't see it as a good idea. > principled methodology from a hardcore type system perspective, we > believe it is very pragmatic and interoperates well with the > dynamically typed world of PHP. It's been extremely important to us I don't see how having strict typing and then making exceptions for "dynamic typed world of PHP" makes much sense. If we want dynamic typed world, we should do what Ruby, Python, Javascript and others do. If we want to go to strict typing direction instead, we should provide guarantees that strict typing is for. Having strict typing without guarantees makes very little sense to me. > There is always an easy escape hatch. If you require subclasses to The point of strict typing is not having escape hatches. If you can just put anything into typing system and say "shut up and accept it", then you have no guarantees that any value is of any known type. And the the question is - why bother with strict typing at all? What advantage it gives if it's not guarantees that values have known types? > 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 "this" is not a type in PHP. "self" is, which is the type of the class it is mentioned in. > of more things than just the literal variable "$this" ("new static" > for example is also of type "this"). But the type "static" is much "new static" in PHP is not of a known type statically. Dynamically, it is of a type that the method was called with, which is signified, somewhat confusingly, by the keyword "static" even though it is actually not static as dynamic (yes, I know, welcome to the wonderful world of keyword reuse). > more consistent with the existing LSB language, i.e., "new static".. > So is there any reason to call it "self" over "static" or "this"? "self" and "static" are two distinct type keywords. "this" is not a type keyword at all, is there a need for yet another type keyword? I don't think so. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227