Re: Implementation help needed: Currying RFC
Hi Johannes,
Thank you very much for your detailed feedback.
Am 07.06.11 12:40 schrieb "Johannes Schlüter" unter
<[email protected]>:
[...]
>I wonder how your proposal would work with a variable number of
>arguments.
>
>Taking a piece out of your RFC:
> $apos = curry strpos(..., 'a'));
>Would the parameter always be appended? So what would happen here:
>
> $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?
Clarified this specifically in the new error handling paragraph. It should
throw a warning/notice in cases 3 and 4, stating that the parameter is not
used.
>I feel that this won't fit easily in the language, while the feature
>itself can be nice with all these callback things. I also don't know if
>it can be implemented in an efficient way. A simple way to implement is
>to create a closure. (which has performance impacts and misleading error
>messages in the cases shown above)
Explained more detailed in the RFC, how I would try implementing it
(indeed with closures or a specialization of them, look at the new
paragraph „Implementation details").
>I also think that
>
> Keyword curry should have an alias schoenfinkel
>
>should not be the case. It is nice to remember some people and such but
>I think this alias is just one more thing to know when reading code but
>serves no real purpose. I know the concept mostly as currying, Scala for
>instance seems to always reference it as currying.
As I set on #pecl.php, I will not fight for this alias :). So removed in
the RFC.
With regards,
Lars
Thread (10 messages)