Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: David Abrahams (dave_at_[hidden])
Date: 2010-09-27 18:35:49

At Mon, 27 Sep 2010 18:09:16 -0400,
Eric Niebler wrote:
> On 9/27/2010 5:06 PM, David Abrahams wrote:
> > At Mon, 27 Sep 2010 15:57:49 -0400, Eric Niebler wrote:
> >> I want to say that a SpiritParser is a SpiritNode<plus> OR a
> >> SpiritNode<right_shift> OR a SpiritNode<terminal> (the plus and
> >> right_shift concepts being recursively defined in terms of
> >> SpiritParser,
> >
> > I showed you how to handle it above.
> You showed me (in broken code according to Sebastian)

Yeah, I fixed it in a followup message. I told you my memory was dim
and there would be nits to pick!

> how to define a concept that, AFAICT, is useless.

As I said, of course I didn't put any content in it because you didn't
tell me what operations it needs to have.

> > You're thinking about this the wrong way. Concepts are a
> > rule-based system, and you're approaching them functionally. It's
> > a totally different programming paradigm.
> This doesn't help me understand it.

Well, it should. You keep beating your head against the "write a
metafunction to calculate this and that" wall, and I'm telling you,
"there's a wall there." If that has made you start looking in
other directions for understanding, then it helped, even if you don't
completely understand yet. If it didn't, well...

You have to approach this from the POV of how concepts are used,
*fundamentally*. You can't take a bunch of existing metaprogram code
and tack on concepts as a constraint mechanism later. That works with
generic code, which is written with concepts in mind, but not with

> >> the terminal concept having little more than a
> >> value_type typedef and a member), the intersection of all those
> >> concepts would have exactly nothing. So I couldn't do anything with
> >> it from a constrained context. What have I missed? How is the
> >> SpiritParser concept you've defined above supposed to be used?
> >
> > Heck if I know; it's your library, man! It's empty because I don't
> > know what operations your operator= needs from it.
> <shrug> I leave this conversation as I leave every conversation about
> concepts: just as confused as when I started. I write template libraries
> and care about error messages. Concepts were billed as a way to improve
> error messages from template libraries.

That is one benefit available to a wide range of template libraries.
Certainly, generic libraries accrue that benefit. I don't know
whether Proto or Spirit could.

> And yet nobody can tell me how to actually use concepts to implement
> my libraries and improve error messages.

I know you know the generic programming process, since we taught a
course on it together. You have to start at the beginning and
discover the concepts by looking at concrete algorithms, lifting out
common requirements, and clustering those into concepts. If that
doesn't work in your problem domain, concepts might not be an
appropriate mechanism for what you want to. But I wouldn't draw any
conclusions about what's possible without first trying it.

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at