Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67879 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44103 invoked from network); 26 Jun 2013 14:59:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 14:59:35 -0000 Authentication-Results: pb1.pair.com header.from=florinpatan@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=florinpatan@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: florinpatan@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:49644] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/13-29746-6D10BC15 for ; Wed, 26 Jun 2013 10:59:34 -0400 Received: by mail-ob0-f170.google.com with SMTP id ef5so13694561obb.29 for ; Wed, 26 Jun 2013 07:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=9PtJ4ZbEbnEsM0b8Gz59EzPAbuTSEggT/q/es/p4Xec=; b=fsZlYWvZ1tF24rs1hmOV6Y3+QJuNa7XeEu3yKThL7taBYNHX3KxRz5TGw+csOsbacp gzUQhjf6mwtXE1ludXcjuxILaDe/Yj2Yd8zwybcqEC2bf7Er6TCoQgo5j/dCqLP0IT14 6GQ0GldQDuD0QlL5mTxRn6k5zSu0Jitrz6W/K95pm7mWIkdrVSnLDSHcU83pYWcfAmYy 3N2LFojDwJZot5yyqEbeKYG+7UIqOsnZdjMSxiQckxOKO5GYGq4umieMMSynN7Z5RD6y MXwsLcH45ypJVBzeinI7uE296fPeMoxeNRDzNdyoh57tiUZ6seXx97lCaIaLNiIS/PXa YFUQ== X-Received: by 10.60.84.147 with SMTP id z19mr664431oey.21.1372258772105; Wed, 26 Jun 2013 07:59:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.18.161 with HTTP; Wed, 26 Jun 2013 07:59:02 -0700 (PDT) In-Reply-To: <1372258135.2410.22.camel@guybrush> References: <1372258135.2410.22.camel@guybrush> Date: Wed, 26 Jun 2013 16:59:02 +0200 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Ferenc Kovacs , Patrick ALLAERT , Julien Pauli , Maxwell , Sherif Ramadan , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Request for comments - new PHP feature: return typing From: florinpatan@gmail.com (Florin Patan) On Wed, Jun 26, 2013 at 4:48 PM, Johannes Schl=C3=BCter wrote: > On Wed, 2013-06-26 at 16:40 +0200, Ferenc Kovacs wrote: > >> > >> I think that the return typehints a bit easier topic than the input type >> hinting(for scalars), because that affects the caller, while return type >> hinting is more contained: you write the function, you put the return >> typehint there, if the method tries to return something else, then your >> code is at fault. >> So even if we would allow return typehints for scalars that would only >> affects those functions where the developer opts-in. > > So a function author doesn't trust himself and therefore we change the > language syntax? > > johannes > All, Thanks for the feedback so far. I've added the typing for scalars as I thought it would be nice to have them but if it's easier to start with supporting what we already have for argument hinting then it would be a great win for the language nonetheless. To address the performance concern issues, I think the performance issues should be very little, like a call to instanceof for example, but I can't say for sure. Of course benchmarks for the actual implementation will need to be made and a manual entry should note that using this feature might have a performance impact if really needed (as I would imagine in 15000 function calls, something that you might see in todays frameworks it could have a more visible impact). @johannes it's not about the author of the function doesn't trust itself, it's about I'm writing a interface and I expect to receive a array but someone returns a string or a single value. That's why I've said that the feature is more about code quality that new toys for developers. Those who opt-in for using this in interfaces would guarantee that every implementation of their interface would be consistent in return type, just like what we have today for arguments, where you can guarantee that you'll have the type you need in your method. If the feedback will be positive for this, as it is right now, I would also like to start working on a patch for this in 2-3 weeks maybe so this is a early request for help for anyone that could point me out in the right direction or champion this patch. I'll make another request when I'll be ready to start working on the patch. Best regards. ---- Florin Patan https://github.com/dlsniper http://www.linkedin.com/in/florinpatan