
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.
Thanks for the detailed explanation. Things are much clear now. Manjunath