Boost logo

Boost Users :

Subject: Re: [Boost-users] [proto] const-ness of references
From: Eric Niebler (eric_at_[hidden])
Date: 2010-03-08 21:29:45


On 3/5/2010 4:38 PM, Manjunath Kudlur wrote:
>> Well, your domain's generator is a little unusual in that not all the
>> expressions it generates are, in fact, within your domain. That's not a
>> stated post-condition of the Generator parameter, but it probably should be.
>> In short, make_expr is assuming that the generator is returning a new
>> object, and so it is storing it by value.
>
> In my case, I am treating the domain mechanism as a means to add a new
> property to my expression. I want that property to hold only for the
> expression of the form Program_(...), and that's why I have the
> generator the way it is. To be honest, I assumed that you provide the
> domain mechanism just for this purpose (i.e., add new properties to
> expressions).

Yes, that's one of the purposes of Proto domains. I was making an
important point that you may have missed. This is how things are
intended to work:

1) All proto expressions have an associated domain. If you haven't
specified one, it is proto::default_domain.

2) All proto domains have an associated generator that, given an
expression in the default domain, puts it in the specified domain by
adding a domain-specific wrapper. (This is where domain-specific
properties and behaviors go.)

3) An expression can only be in one domain (in the current
implementation). A domain can have only one generator. There may be many
domain-specific wrappers in each domain, each that presents a different
interface. The generator's job is to add the right wrapper to a given
expression. Most of the time, there is only one wrapper but that need
not be the case.

4) All operations on proto expressions produce new expressions in the
same domain as its constituents.

When I said that your generator was unusual, it was because it doesn't
follow (2) above ... the expression emitted by your generator is
sometimes in the program_domain, and sometimes in the default domain.

Look again at the code I posted back on March 1:
http://article.gmane.org/gmane.comp.lib.boost.user/56408

There are two wrappers with two different behaviors, both in the same
domain. The generator always produced expressions in the same domain,
but sometimes with different behaviors. This is what you want.

<snipping the rest because I don't have time to look in detail right now.>

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