|
Boost : |
Subject: Re: [boost] painless currying
From: Eric Niebler (eric_at_[hidden])
Date: 2011-08-26 14:58:57
On 8/26/2011 2:05 PM, Dave Abrahams wrote:
>> Eric Niebler wrote:
>>> I don't see any technical obstacles to:
>>>
>>> f(_, y, z)
>>>
>>> where _ is a placeholder. You could use positional placeholders for
>>> argument reordering.
>
> That's more general than straight currying, and it's clearer: f(x,_,_)
> is a curried version of f that is a bit more explicit about what it
> means than just writing f(x).
>
>> You might say the syntactic advantages of this over bind(f, _, y, z) are
>> minimal. You might be right.
>
> I wouldn't say that. I like the placeholder syntax; it's similar to
> what MPL does, and frankly I had assumed we already had libraries
> (phoenix?) that did things this way.
All the library solutions we have so far involve an explicit call to a
function named "bind" or similar.
> The only question is what happens
> when you write f(x,y,z). IIUC, phoenix leaves you with a nullary
> function, but you're proposing to actually call f. I'm just not sure
> that's quite as appropriate in C++ as it is in Haskell. Suppose you
> *wanted* a nullary function object (e.g. so you could launch a thread
> with it) rather than its result. Then you need to switch to a different
> syntax for the final argument?
Ah, thank you. Good point. I think I'll let this issue drop now.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk