Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37243 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57743 invoked from network); 26 Apr 2008 08:01:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Apr 2008 08:01:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 208.70.128.103 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 208.70.128.103 smtp-gw77.mailanyone.net Received: from [208.70.128.103] ([208.70.128.103:38701] helo=smtp-gw77.mailanyone.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/38-07863-E41E2184 for ; Sat, 26 Apr 2008 04:01:18 -0400 Received: from mailanyone.net by smtp-gw77.mailanyone.net with esmtpsa (TLSv1:AES256-SHA:256) (MailAnyone extSMTP sam@sambarrow.com) id 1JpfLP-0006wS-Pv; Sat, 26 Apr 2008 03:01:16 -0500 To: Alain Williams Cc: internals@lists.php.net In-Reply-To: <20080425231305.GC14490@mint.phcomp.co.uk> References: <1209137410.6642.9.camel@sbarrow-desktop> <1209147362.20639.7.camel@sbarrow-desktop> <20080425182341.GB14490@mint.phcomp.co.uk> <1209149047.20639.18.camel@sbarrow-desktop> <48122C14.7070705@omegavortex.net> <1209150944.20639.24.camel@sbarrow-desktop> <7dd2dc0b0804251224s750679acn169637efbd8653fa@mail.gmail.com> <1209151505.20639.25.camel@sbarrow-desktop> <20080425231305.GC14490@mint.phcomp.co.uk> Content-Type: text/plain Date: Sat, 26 Apr 2008 04:01:15 -0400 Message-ID: <1209196875.7324.0.camel@desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return type hinting patch From: sam@sambarrow.com (Sam Barrow) I like the first too, if this can be implemented I think it is a suitable syntax. On Sat, 2008-04-26 at 00:13 +0100, Alain Williams wrote: > public function int doThing(string $foo) { return 1; } > > The above is the best (ie omit 'return' or 'returns'). > > This also is consistent with C and with the way that the manual is written, eg: > > http://www.php.net/manual/en/function.strlen.php > > The only argument is the relative ordering of the keywords. > We keep 'function' - since that is the way that the language works. > Things like 'public' we put before 'function' since that is the way that > it works in PHP 5 objects. > > So the only thing to decide is where the type goes: > > public function int doThing(string $foo) { return 1; } > > or: > > public int function doThing(string $foo) { return 1; } > > I would favour the first one, this is probably also easier to parse, as > following 'function' and before '(' you can have: > > * 1 word - which must be the name of the function > * 2 words - the first word is the return type, the second the function name. > > If the function returns a reference to something of a particular type, where > does the '&' go: > > public function &int doThing(string $foo) { return 1; } > > or: > > public function int& doThing(string $foo) { return 1; } > > I would suggest the second, ie just before the function name. > > -- > Alain Williams > Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. > +44 (0) 787 668 0256 http://www.phcomp.co.uk/ > Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php > Chairman of UKUUG: http://www.ukuug.org/ > #include >