Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54453 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 433 invoked from network); 8 Aug 2011 07:17:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2011 07:17:32 -0000 Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 87.106.212.190 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 87.106.212.190 s15355703.onlinehome-server.info Linux 2.6 Received: from [87.106.212.190] ([87.106.212.190:60103] helo=s15355703.onlinehome-server.info) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/2D-17758-64D8F3E4 for ; Mon, 08 Aug 2011 03:17:27 -0400 Received: from hwhost.local (85-218-15-56.dclient.lsne.ch [85.218.15.56]) by s15355703.onlinehome-server.info (Postfix) with ESMTPA id 33FEBE4018 for ; Mon, 8 Aug 2011 09:16:20 +0200 (CEST) Message-ID: <4E3F8D43.7000404@hoa-project.net> Date: Mon, 08 Aug 2011 09:16:19 +0200 Reply-To: ivan.enderlin@hoa-project.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Add \Countable support to \Closure From: ivan.enderlin@hoa-project.net ("Ivan Enderlin @ Hoa") Hi Internals, I would like to suggest you a new feature (for PHP5.4 or maybe next).=20 The idea is to implement the \Countable interface into closures to=20 easily count the arguments number. I know that it is already possible=20 with reflection [1] but it could be a comfortable trick I think. Subsidiary questions: do we include optional arguments in our calculation= ? Here is a trivial example: class Closure implements \Countable { =85 } $f =3D function ( $x, $y, $z ) { =85 }; var_dump(count($f)); // int(3) Javascript already implements this [2]: var f =3D function ( x, y, z ) { =85 }; console.log(f.length); Thoughts? Best regards. [1] [2]=20 --=20 Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ Member of HTML and WebApps Working Group of W3C http://w3.org/