Jason Merrill wrote:
On 08/04/2009 09:35 AM, John Freeman wrote:

In my opinion, lambdas are not intended as just a shortcut to writing a
function object class. This is why our proposal did not require that
lambdas be implemented as classes; it is simply one implementation.
(Awaiting word to see if this is still the case in the working draft of
the standard; it may not be, but that doesn't change my opinion :)

From N2859: "The type of the lambda-expression (which is also the type of the closure object) is a unique, unnamed non-union class type—called the closure type...."

Yes, this is the wording I'm worried about (it changed in N2914, but is similar). I don't think it was in our original proposal. I'm awaiting a response from Daveed Vandevoorde to see if it prescribes an implementation.


IMO, it's better to define new functionality in terms of already familiar features rather than have to specify everything about how a new feature interacts with the rest of the language.

Right. We defined the new functionality in terms of existing functionality for just this reason, but we did not prescribe an implementation (similar to other features in the standard). Granted, a class is the obvious and intended implementation, but we don't want to prevent optimizations where possible, as long as they preserve behavior. I'm not sure if this allowance is implicit in the wording; I'm not a standardese expert. Hopefully, this answers the below as well.


In response to Jason's concern here, a template implementation is not
required, just convenient. Hopefully you won't think of it as "templates
without template syntax", but "deduction using the existing template
mechanism".

As above, suggesting that it doesn't have to be a template suggests that there's a lot more specification left to do, such as how do you deal with expressions whose type you don't know yet? If you allow non-lambda uses, how do they fit into overload resolution? If you just say it's a template, we already know how they work.

Reiterating, to allow more freedom in implementation, we can just say it "behaves as" a template, rather than "is" a template.

- John

Reply via email to