Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78695 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57453 invoked from network); 5 Nov 2014 01:06:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Nov 2014 01:06:35 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.177 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.177 mail-ob0-f177.google.com Received: from [209.85.214.177] ([209.85.214.177:50529] helo=mail-ob0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 69/A0-54119-A1879545 for ; Tue, 04 Nov 2014 20:06:35 -0500 Received: by mail-ob0-f177.google.com with SMTP id m8so11418351obr.36 for ; Tue, 04 Nov 2014 17:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=tDAsMPFWlEXVdQXFdbw8XEPVPidXG8u6z/P8aW5tJYs=; b=UEYL7xG7Im0RxGW9YEspR5MRqHC0JHWmlzWg5M4hIej4OYxE6RHS5f5eiStOwcMC5n vqbMZrM2AjzhNEfYL/mR3WxYe5S/zFLn+pmsctIqHe9B/qjDAHL1n66R2m+pL+5zxvR1 C2OJOYPgVUCxblgPM13A9WW08je53cxEpMFV3iG8sFeS1Vokses2/bcaHQ++xSrEvSkj 5Uy9KriF22CiTGkkJS4zMI5jwEqTNpsRHqAsXsACW8LIRwH5/PXyq5csBmbMLMbKgKyo uYFGkTwRFa1iw1zQ8ell4gjiicNGWnhwuKCDVvunY/7Et7gjkyu8cvSLDSqkFWL866LU 2t5Q== MIME-Version: 1.0 X-Received: by 10.202.184.86 with SMTP id i83mr12661283oif.51.1415149591418; Tue, 04 Nov 2014 17:06:31 -0800 (PST) Sender: morrison.levi@gmail.com Received: by 10.76.159.163 with HTTP; Tue, 4 Nov 2014 17:06:31 -0800 (PST) In-Reply-To: <5459756C.5010806@lerdorf.com> References: <002601cff777$eb923430$c2b69c90$@tutteli.ch> <000601cff80a$972e0250$c58a06f0$@tutteli.ch> <5458937F.9020304@sugarcrm.com> <545910F1.8030904@sugarcrm.com> <859A97F0-7C58-406A-857B-557F8AA657AD@ajf.me> <545917A2.6000206@lerdorf.com> <5459756C.5010806@lerdorf.com> Date: Tue, 4 Nov 2014 18:06:31 -0700 X-Google-Sender-Auth: BjoEDMeFFAqnLnbB4YF-NVUIll8 Message-ID: To: Rasmus Lerdorf Cc: Andrea Faulds , Stas Malyshev , Leigh , Robert Stoll , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Types on the right or on the left From: levim@php.net (Levi Morrison) On Tue, Nov 4, 2014 at 5:55 PM, Rasmus Lerdorf wrote: > On 11/04/2014 04:42 PM, Levi Morrison wrote: >>>> If we used this syntax instead, which wouldn=E2=80=99t disrupt grep: >>>> >>>> public Foo function bar(); >>>> >>>> It=E2=80=99d be inconsistent with normal function declarations which w= ould have to have Foo after function. >>> >>> I don't understand that inconsistency. >>> >>> public Foo function bar() { } >>> >>> looks perfectly sane to me. PHP's syntax was very heavily influenced by >>> C from day 1. In C you have: >>> >>> static int bar() { } >>> >>> In PHP the 'function' keyword indicates what follows is a function. >>> Putting something in between the function keyword and the name of the >>> function would confuse me. To me "function bar()" is inseparable and is >>> equivalent to "bar()" in C which makes the above examples consistent >>> with each other. >> >> Except `static function()` and `static function foo()` already have >> meaning, and if we allowed static return types (very possible) that >> would be ambiguous. This syntax is a no-go. > > static isn't a type it is a scope. You want to expand return types to > also cover scopes? How is that in any way useful? Basically because the return type would depend on the scope that called it. This is done in production, for better or worse, already: class A { public static function make() { return new static(); } } class B extends A {} var_dump(B::make()); //object(B)#1 (0) { //} People have been asking for support; it's just out of the scope of this RFC= .