|
Boost : |
Subject: Re: [boost] Call for interest - BOOST_AUTO_FUNCTION
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2010-10-18 12:25:50
On Mon, Oct 18, 2010 at 11:14 PM, David Abrahams <dave_at_[hidden]> wrote:
> At Mon, 18 Oct 2010 22:17:25 +0800,
> Dean Michael Berris wrote:
>>
>> Does it help the argument for a change if a macro can do the job?
>
> Maybe; I don't know.
>
Worth a shot then. :)
>> I mean, what can a preprocessor macro do that the compiler can't
>> built-in from the front-end? :D
>
> âLook aheadâ without processing the code semantically.
Ah. Hmmm... that's a tough one.
But then how does the compiler do something like deduce the return
type of a lambda?
auto f = [](int x) { return x * 2; }
Shouldn't the same mechanism be available in normal function
declarations even without the computation of the return type? I would
love to be able to write functions that look like:
auto f(int x) {
return x * 2;
}
This does mean though that the auto function without a trailing return
type cannot be 'extern' -- and would most likely behave like a
template function.
Anyway, I think that suggestion wasn't well thought out but I'm
throwing it out there anyway.
> âImplementabilityâ is not a question of whether it can be implemented
> at all, but of whether it can be implemented reasonably within the
> architecture of existing compilers. Â If it requires a ground-up
> redesign of some major compiler, it's effectively unimplementable.
>
Right, because that would mean C++0x is not an incremental change to
C++03. Understood.
>> I also doubt the committee members weren't paying attention. The
>> standard is already huge as it is and diving deep into the details
>> (and the aesthetics) of the implementation of one specific feature is
>> time and effort consuming.
>>
>> I really hope it's not yet beyond repair at this point. :)
>
> I wouldn't hold out much hope that this can happen for C++0x, unless
> you can convince some national body that it's so important that the
> standard should be rejected if they don't get it. Â That's what
> happened for exception-safety. Â But that sort of thing is rare.
>
Yeah, well in the worst case Boost would have a library pending for
review (I assume) that does offer the ability to write one-liner
functions with trailing return types through a preprocessor macro. Not
that bad IMO, maybe it can be made part of C++1x. :)
-- Dean Michael Berris deanberris.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk