Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] implementing an computer algebra system with proto
From: Eric Niebler (eric_at_[hidden])
Date: 2009-01-28 12:03:24


Dave Jenkins wrote:
> "Eric Niebler" <eric_at_[hidden]> wrote in message
> news:49807DB5.2080307_at_boost-consulting.com...
>> You're passing an expression to a grammar to be evaluated with its
>> transforms. That expression must match the grammar. It's undefined
>> behavior if it doesn't, and in this case, it doesn't. "Performing the
>> transform" falls withing UB.
>>
>> It would be possible to add a compile-time check to all grammars
>> function call operators to catch this error, but that comes with a
>> compile-time cost.
>
> I think it would be a useful check. Could you either
> (1) always check in proto::exact

That would essentially involve a full evaluation.

> (2) check when a compile time flag is defined

That is not a half-bad suggestion. It's funny that we have NDEBUG to
avoid costly runtime checks but no equivalent for costly compile-time
checks.

I've never particularly cared for the "N" in "NDEBUG" ... it seems the
wrong default. Perhaps we can have a boost-wide macro for expensive
compile-time checks. How about BOOST_COMPILE_TIME_DEBUG?

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net