Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78632 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22777 invoked from network); 4 Nov 2014 12:46:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2014 12:46:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=are.you.winning@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=are.you.winning@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.46 as permitted sender) X-PHP-List-Original-Sender: are.you.winning@gmail.com X-Host-Fingerprint: 209.85.192.46 mail-qg0-f46.google.com Received: from [209.85.192.46] ([209.85.192.46:51649] helo=mail-qg0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/E2-06676-2AAC8545 for ; Tue, 04 Nov 2014 07:46:26 -0500 Received: by mail-qg0-f46.google.com with SMTP id i50so9356199qgf.33 for ; Tue, 04 Nov 2014 04:46:23 -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; bh=AxuX7V6WFHw5opV8Mq7ruiZLBsZ68kHjG9QVvaIkfmw=; b=XA2LaraNlPpKTRBuZNR5wD3mLb63U7uy+UweVle4mW2omu2VzqK46eCi/Qdg8hhLiP SU+2UTksY5Txi88lP0FUdfjN4Z63UkoVGEZJqqdZ1CvzDMTVOGfmnFjphBpUclfCh6aN BsoabspniThv+xPwdN9Aw+AYnRDsuhXCiVcbj0U5olHzBiqU7VgsBOnQIFm0l/U9fLyo VhUUqJ+aHtShnj7g4HrUIp3FAWKhy7HXHcLIWdw6MZtsvU381v5SlIR5nJlELQ23GAb8 CHhLnu5p3dL6HzOJqzlG4pusVYXfHr87A/1me8mzlPtSG/tF++n7bp6rRvu++Ju/QQff HKGA== MIME-Version: 1.0 X-Received: by 10.140.101.120 with SMTP id t111mr72075831qge.6.1415105183466; Tue, 04 Nov 2014 04:46:23 -0800 (PST) Sender: are.you.winning@gmail.com Received: by 10.140.239.194 with HTTP; Tue, 4 Nov 2014 04:46:23 -0800 (PST) In-Reply-To: <001d01cff829$5010a750$f031f5f0$@tutteli.ch> References: <002601cff777$eb923430$c2b69c90$@tutteli.ch> <000601cff80a$972e0250$c58a06f0$@tutteli.ch> <5458937F.9020304@sugarcrm.com> <0776A65F-D49A-4E8C-9771-6B5E5C4EA77E@ajf.me> <001d01cff829$5010a750$f031f5f0$@tutteli.ch> Date: Tue, 4 Nov 2014 12:46:23 +0000 X-Google-Sender-Auth: 9BAqghxL5dVckhZBc-5NiVXm3S0 Message-ID: To: Robert Stoll Cc: Chris Wright , Andrea Faulds , Stas Malyshev , PHP Internals Content-Type: multipart/alternative; boundary=001a11c15d7ec7c9da050707d9a0 Subject: Re: AW: [PHP-DEV] Types on the right or on the left From: cw@daverandom.com (Chris Wright) --001a11c15d7ec7c9da050707d9a0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 4 November 2014 12:17, Robert Stoll wrote: > > > -----Urspr=C3=BCngliche Nachricht----- > > Von: are.you.winning@gmail.com [mailto:are.you.winning@gmail.com] Im > Auftrag von Chris Wright > > Gesendet: Dienstag, 4. November 2014 12:51 > > An: Andrea Faulds > > Cc: Stas Malyshev; Robert Stoll; PHP Internals > > Betreff: Re: AW: [PHP-DEV] Types on the right or on the left > > > > On 4 November 2014 10:32, Andrea Faulds wrote: > > > > > > > > > On 4 Nov 2014, at 08:51, Stas Malyshev > wrote: > > > > > > > > I agree, this is not a very good situation. It would be much better > > > > to take a systematic approach to this, but this is impossible since > > > > there is no systematic approach to strict typing in PHP, just some > > > > pieces here and there. I think this is not right, but obviously man= y > > > > people here disagree and are happy to have the inconsistent syntax. > > > > I don't see why "public Foo function bar()" would be so much worse > > > > than "public function > > > > bar() : Foo" but for some reason this possibility wasn't even > > > > considered as far as I can see. > > > > > I thought it was inconsistent, but after discussions on StackOverflow, = I > > > don't think it actually is. Return types describe the return type of = a > > > function, not the type of a function. So there's no reason they have > > > to go before the function name like parameter types do. > > > > > > > > So, in a sentence: > > > > In PHP, input types go on the left and output types go on the right. > > > > This sounds like a convention that could be established and followed, > and no-one could reasonably call it inconsistent if it > > was adhered to. > > That is an interesting thought. Yet, where would you put the type of an > out parameter then? I wouldn't, because this wouldn't ever make sense in PHP. I'm not a fan of out parameters in general in PHP, but enforcing the output type of a variable can't ever make sense in PHP from an implementation perspective without sacrificing some dynamic features that won't ever disappear - I'm sure it could be done, but not without a huge and unacceptable performance penalty. > Nevertheless, you could phrase your convention differently so it makes > more sense and well.. in the end we can do whatever we like in PHP and > call it xy-convention and the user will have to pick it up and learn it > (quite similar to array functions where usually the first argument is arr= ay > and suddenly it is not the first parameter as with array_key_exists, > array_map or array_search). Sure it is no big deal, the user should be ab= le > to pick up the convention quickly but we could facilitate it, make it > easier for the user, more intuitive, in order that the user has a steeper > learning curve. And the time to decide what direction PHP should take is > now with PHP 7. > Please remember that PHP 7 is not the last major version of PHP. The things we do now are set in stone, but they do not mean that something else cannot be done in the future to build on top of them, as long as they do not conflict. I guess it's worth noting that my *personal* opinion is that I'd also rather have the function return type declaration on the left (I'd also like to drop the requirement for the "function" keyword in method declarations), but since there are a number of reasons why this no longer makes sense, and will never make sense again, I didn't hesitate to vote in favour of the current proposal because more than anything else I think the feature is what is important, and I know how much work has been put in to ensuring that the proposal satisfies as many concerns as possible. There will never be a better proposal than this. --001a11c15d7ec7c9da050707d9a0--