Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: Eric Niebler (eric_at_[hidden])
Date: 2010-09-24 21:29:47


On 9/24/2010 9:58 PM, Robert Ramey wrote:
> Eric Niebler wrote:
>> On 9/24/2010 8:22 PM, Robert Ramey wrote:
>>> would all this boil down to the following guidlines.
>>>
>>> a) All template libraries should use boost::concepts ?
>>
>> Certainly Concept_check or something like it has a big role to play in
>> this. But I wouldn't know how to use Concept_check to verify that an
>> expression template matches a grammar, for instance. It's not the
>> whole story. Though perhaps I don't know enough about the
>> concept_check library to see how it can apply to proto expressions
>> and grammars. Suggestions?
>>
>> Also, I would prefer C++0x static_assert to the concept_check macros
>> because the error messages can be much nicer. I think the answer is
>> that the concept_check library badly needs a C++0x makeover.
>
> Hmm - so the above guidline would be sufficient if the
> concept_check_library were subjected to a makeover?

Possibly. Likely, even. I just don't know enough to say.

> Your article makes a point that libraries should check template
> parameters. It's my understanding that this is the intention of
> boost concept checks. I'm not sure where "verify that an expression
> template matches a grammar" fits in here.

Expressions are interesting in that they have such rich compile-time
structure. Think of XML documents. Grammars are like XML Schemas; they
describe which XML documents are valid. I just don't know how to match
the schema/data model on the concept/type model. What is the concept
satisfied by a Spirit rule? Or a Phoenix lambda expression? I've never
seen a concept like that.

I guess what I'm wondering is if concepts are really powerful enough to
describe types like that.

>>> b) All template libraries should try to factor implemenations so that
>>> compile errors are not propagated?
>>
>> Yes. And: detailed comments should be left near any static assertions
>> or concept checks, since that's where the unlucky few will end up.
>
> I've been doing ths all the time. It's more than a few that end up there.
>
> Just to sum up would the following be sufficent to implement your idea?
>
> a) makeover of concept_check
> b) wider usage of concept_check
> c) refactoring to truncate listings of compiler errors
>
> Obviously I'm trying to boil this down to something that can
> be verified in an objective way.

With the above caveat about whether concepts are powerful enough, yes.

-- 
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