Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53153 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21701 invoked from network); 7 Jun 2011 15:09:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2011 15:09:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=martinscotta@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=martinscotta@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martinscotta@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:59809] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/41-15404-14F3EED4 for ; Tue, 07 Jun 2011 11:09:54 -0400 Received: by vwl1 with SMTP id 1so4131917vwl.29 for ; Tue, 07 Jun 2011 08:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=RH4m11IldJXPB/yhLIz0N01Jp8cBgKNQ4pTx1HjvBug=; b=hCTXp+21wI5tsSHMMn2rO13D4yPTXJYBW7mCMMVVO51O3UAK5KOurgXip8RiRWyt/M t6QGzpyaNL5oN87e/MgjUNEYTIun3fQsoJcwVderepXhQ3c9bYMJHB5oKsaed504KNtf WlNRdxB0YPxLZnePhLN8s1efPA2R8A34lEWBQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=MSsArvJ86j4dZaUupuAQUjXuINAr1gSgl7OAiCTupHQZMlBSzo469eGk/ZYLUjVWPC wM5UxNNCcO9QLPbZ6JGVrJAKbmlUeT5HaIZw0hb+akC2PY17U2gBfF4Ui86DShSOXbhQ K2YZ8THS/cFFPyYUTILIFYdWZWtdKMt8wC2eo= MIME-Version: 1.0 Received: by 10.220.189.131 with SMTP id de3mr1338710vcb.48.1307459390624; Tue, 07 Jun 2011 08:09:50 -0700 (PDT) Received: by 10.220.192.129 with HTTP; Tue, 7 Jun 2011 08:09:50 -0700 (PDT) In-Reply-To: References: <1307443213.1894.848.camel@guybrush> Date: Tue, 7 Jun 2011 12:09:50 -0300 Message-ID: To: John Crenshaw Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=90e6ba53aa1c8955b304a5209c7c Subject: Re: [PHP-DEV] Implementation help needed: Currying RFC From: martinscotta@gmail.com (Martin Scotta) --90e6ba53aa1c8955b304a5209c7c Content-Type: text/plain; charset=ISO-8859-1 Martin Scotta On Tue, Jun 7, 2011 at 10:43 AM, John Crenshaw wrote: > > $apos = curry strpos(..., 'a')); > > $apos(); // runtime error wrong param count? > > $apos("bar"); // fine > > $apos("bar", "foo"); // 'a' casted to long, used as offset? > > $apos("bar", "foo", 0); // run-time error wrong param count? > > I understand where this can be useful sometimes, but I disagree that this > should be added as a language feature. It is still possible to implement > this (parameter positioning in your curried function) using a function that > returns a closure similar to the curry_left example in the RFC. One possible > method (inspired by the C++ system for doing the same thing) would be: > > $apos = curry( 'strpos', _1(), 'a' ); // _1() returns a placeholder > positioning object > > This isn't quite as nice as the proposed T_FILL, but on the other hand, it > is more powerful (parameters could change order) and isn't nearly as > confusing as the RFC syntax (which looks like perhaps strpos is being called > in some strange way). > > Of course, there is also always the regular old closure, which is far more > explicit and leaves no confusion about exactly what is being returned. > > No offense to anyone who loves currying, but I don't see why this should be > implemented. There are plenty of good options available for achieving > identical or better results without modifying the language. > > Hey Jhon, What about writing your curry idea in plain PHP, as a proof of concept. Then you can show examples live and others can toy with it. I'm pretty sure most php developers are not used to curry -- or at least those who don't have functional programming skills > John Crenshaw > Priacta, Inc. > --90e6ba53aa1c8955b304a5209c7c--