|
![](/i/fill.gif) |
Am 22.04.2012 17:40, schrieb Orchid Win7 v1:
> On 22/04/2012 11:40 AM, Warp wrote:
>
>> But that's the thing: It sounds so trivial as to defy sense. Why give
>> a particular name to such a trivial thing?
>
> One could argue that "calling a function" is a pretty trivial idea. But
> it's still useful to have a name for it.
>
>> But then when one starts asking questions like "so it's like giving
>> default values to function parameters?" or "so it's like writing another
>> function with less parameters that calls the first function by giving it
>> some default values as the rest of the parameters?", the answer is
>> something
>> like "not really".
>
> Providing default arguments is /kind of/ similar. The difference is that
> usually you /can/ still provide explicit values which override the
> defaults. With a curried function, you /cannot/ change the arguments
> that have already been given. (Or even know if any arguments /have/ been
> give yet. All you can see is what arguments remain.)
>
> Writing a new function that takes one fewer arguments than an existing
> one is like currying. Except that the idea behind "currying" is that
> this is /automatic/. You don't have to code it yourself. It's
> automatically available for all functions.
Maybe that's what scrambles my mind whenever I read "Haskellists'"
explanations of stuff: They're so proud that Haskell does it
automatically for you, that they tend to deny the obvious parallels.
So yes: Currying *is* like writing a function that takes fewer
arguments, calling the original one and supplying (unchangeable)
defaults for the missing arguments.
And yes, apparently Haskell provides syntactic sugar for that. Wow. Big
deal.
> Finally, like I said, currying works backwards too: If a function call
> happens to return a function as its result, you can just keep appending
> arguments. "head function_list 7" and all that.
Again, nice-to-have syntactic sugar, but nothing conceptually
fascinating (as you noted yourself).
> That said, you could probably design some sort of object that has
> methods for adding arguments, N at a time, and when it gets enough
> arguments, it yields an answer. And that might reasonably be described
> as currying.
No. That might reasonably be described as nothing but bullshit.
Post a reply to this message
|
![](/i/fill.gif) |