|
Boost : |
Subject: Re: [boost] [guidelines] why template errors suck
From: Eric Niebler (eric_at_[hidden])
Date: 2010-09-26 09:04:31
On 9/26/2010 8:51 AM, Mathias Gaunard wrote:
> Jeremy Maitin-Shepard a écrit :
>> Obviously actual timing data would be useful, but it seems that in
>> some cases these techniques might result in increased compilation
>> time, which is at least as serious a problem as the error messages.
>
> Indeed.
>
> The idea, in order to provide better error messages, is to test whether
> all the expressions you're going to evaluate are going to lead to errors.
>
> Then, if they don't, you evaluate said expressions. However, this
> basically ends up doing the same thing twice (or worse, checking the
> expressions are valid may be more costly than actually instanciating
> them) as far as the compiler is concerned.
In the case of a Proto expression, evaluating an expression by applying
transforms (that are embedded in a grammar) will instantiate the same
templates that would be instantiated by checking the expression against
that same grammar. Given that the compiler memoizes template
instantiation, checking an expression against a grammar before
evaluating it *should* be virtually free in terms of compile time.
Benchmarks should be done to back up that claim.
> Therefore I think the solution is to provide a compiler debug mode in
> which we do this testing, and one where we don't.
In general, I agree. I have long thought about adding such a debug mode
to the implementation of Proto itself (which eschews parameter checking
for improved compile times).
-- 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