Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78662 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88789 invoked from network); 4 Nov 2014 18:23:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2014 18:23:36 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.18 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.18 mout.gmx.net Received: from [212.227.15.18] ([212.227.15.18:62981] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/9E-06676-6A919545 for ; Tue, 04 Nov 2014 13:23:35 -0500 Received: from [192.168.0.101] ([91.67.244.80]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LngRb-1YFoKN1uut-00hyOx; Tue, 04 Nov 2014 19:23:28 +0100 Message-ID: <545919A0.6080800@gmx.de> Date: Tue, 04 Nov 2014 19:23:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Andrea Faulds , Chris Wright CC: Stas Malyshev , Robert Stoll , PHP Internals References: <002601cff777$eb923430$c2b69c90$@tutteli.ch> <000601cff80a$972e0250$c58a06f0$@tutteli.ch> <5458937F.9020304@sugarcrm.com> <0776A65F-D49A-4E8C-9771-6B5E5C4EA77E@ajf.me> <28A749C7-A600-4C7A-86A9-7166F2955EE0@ajf.me> In-Reply-To: <28A749C7-A600-4C7A-86A9-7166F2955EE0@ajf.me> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:WxJbHtf8yiyZTiINvDY787B49Ds+s9Kz63YvMSt0Ax4raMF3Oyg SKcz9SYhznds5ZBZlCdqYTcPHZ75KSe5CwUMx95Yjvil5YEQfFNN7xzcTRXFB7huJsx8Jg+ RzweJaEHgzjEEi8SH9EYKEauOghDtH2sdd3XrEy6qYJYypVgz7tujM9vR8CaX6i38/FTNg1 xbDG2OxED+/996mYJXi/Q== X-UI-Out-Filterresults: notjunk:1; Subject: Re: [PHP-DEV] Types on the right or on the left From: cmbecker69@gmx.de (Christoph Becker) Andrea Faulds wrote: > For parameters, the type is of the thing itself: > > function foo(Foo $foo, Bar $bar); > > Here, $foo is of the type Foo, and $bar is of the type Bar. > > But say if we were to add return types like this: > > function FooBar qux(); > > The type of qux isn’t a FooBar, it’s a function (more accurately, an argument-less, return-anything function). FooBar isn’t what qux is, it’s not qux’s type, merely what it returns. In a sense, I’d say there’s already a type here: `function`. > > Compare it to this: > > function qux(): FooBar; > > FooBar is what qux returns, `function` is what qux is. > > If we were to hypothetically add typed properties with the same syntax Hack has, they’d look like this: > > public Foo $foo; > > This would be consistent with parameters. And I think it goes along well with return types at the end: > > public Foo $foo; > public function foobar(): FooBar; > > Here, it’s clear the second item is a function, and the previous item is a property of type Foo. > > …but hey, I could be wrong. Does this make sense to anyone? To me it makes sense. However Foo function foo(Bar bar) {} also makes sense, as the type of bar would be "Foo function(Bar)". -- Christoph M. Becker