Boost logo

Proto :

Subject: Re: [proto] Externalizing grammar pattern matching
From: Eric Niebler (eric_at_[hidden])
Date: 2010-11-23 14:30:28


On 11/23/2010 2:18 PM, joel falcou wrote:
> On 23/11/10 17:20, Eric Niebler wrote:
>> On 11/23/2010 10:19 AM, Joel Falcou wrote:
>>> So, question is: is there a way to have an extensible list of
>>> when<pattern,rule> that can be extended "from the outside", something
>>> like a proto::switch_ but with patterns instead of tag ?
>> No. The best you can do is document how to define a new Proto algorithm
>> from an old one:
>>
>> struct Old : proto::or_< ...> {};
>>
>> struct New : proto::or_< my_stuff, Old> {};
>>
>> Now everywhere in your library that you have the Old algorithm
>> hard-coded, you need to make it a template parameter so that your stuff
>> can be used with an extended algorithm.
> Can't the new extrnal_transform be of any help ?

No. You're not adding transforms. You're adding grammar rules. The
external transforms and proto::switch_ are extensible because they have
unique types off of which to key: rules and tags. There is no unique
type off of which to key in order to add new grammar rules. Phoenix uses
custom tag types with switch_. That's, or my above suggestion, are your
best bets.

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

Proto list run by eric at boostpro.com