|
Boost : |
Subject: Re: [boost] [guidelines] why template errors suck
From: Eric Niebler (eric_at_[hidden])
Date: 2010-09-26 22:31:54
On 9/26/2010 9:44 PM, David Abrahams wrote:
> On Sep 26, 2010, at 8:55 AM, Eric Niebler wrote:
>>
>> On 9/25/2010 1:24 PM, David Abrahams wrote:
>>> On Sep 24, 2010, at 11:51 PM, Eric Niebler wrote:
>>>>
>>>> On 9/24/2010 9:37 PM, David Abrahams wrote:
>>>>
>>>> Haha! No, not at all. Let's rephrase the problem a bit. If we still had
>>>> C++0x concepts, what would the concept SpiritParser look like, such that
>>>> we could define spirit::qi::rule::operator= such that it required its
>>>> RHS to satisfy the SpiritParser concept?
>>>
>>> That's easy to answer; just look at the operations that operator= et. al expect of such a type. Wouldn't SpiritParser just be some simple refinement of Callable?
>>
>> No. rule::operator= expects SpiritParser to be a strongly-typed tree.
>
> Meaning? Spell it out and you have your requirements.
Meaning:
+ If the topmost node has tag-type "plus", there must be exactly one
child node that models SpiritParser
+ If the topmost node has tag-type "shift_right", there must be exactly
two child nodes that model SpiritParser,
+ If the topmost node has tag-type "subscript", there must be a left
node that models SpiritParser and a right node that models PhoenixLambda,
...
etc, etc, etc, ad nauseum
How do I express that as a concept?
>>>> Would it be any more
>>>> illuminating that a simple wrapper around proto::matches<Expr,
>>>> SpiritGrammar>?
>>>
>>> If you want to apply concepts to this stuff (and I'm not sure whether it's really possible), you have to go back to the classic Generic Programming Process: look at concrete algorithms, lift out common requirements, cluster into concepts, etc.
>>
>> Why do you doubt it's possible?
>
> I just don't know.
>
>> If there are template constraints not
>> practically expressible in concepts, then aren't concepts broken?
>
> Not necessarily. Concepts are not about expressing arbitrary template constraints. They're about describing abstractions. One might say that if you can't figure out how to write a concept for a template parameter, you don't understand the abstraction it's modelling.
I understand the abstraction perfectly well. It's a strongly-typed tree
that conforms to a grammar. I haven't a clue how to express that as a
concept. It's not a reflection of my poor understanding of my
abstraction. It reflects my poor understanding of concepts. I'm
sincerely asking for help trying to understand this.
-- 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