|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2007-07-17 14:12:15
Maurizio Vitale wrote:
> Eric Niebler <eric_at_[hidden]> writes:
>
>> Maurizio Vitale wrote:
> <snip>
>>> My mental model was:
>>> - proto::deep_copy traverse the expression top-down replacing references with value.
>> Actually, bottom-up, but yes references are replaced with values.
>
> It is probably terminology, but the following seems top-down to me: you're asked to deep-copy
> an expression and you assemble an expression which has the same shape (tag and argcount) of the
> original and as children the result of recursive evaluations of deep-copy on the children.
Just terminology. You recurse all the way down to the leaves, deep-copy
them and store the results by-value in new parent nodes, all the way
back up to the root. So the first deep-copy is done to the leaves --
hence bottom-up.
<snip>
> I guess my question is what is the difference between:
>
> struct lambda_domain : domain<generator<lambda_expression> > {};
> auto expr = deep_copy(_1 + 42);
>
> and:
>
> auto expr_1 = _1 + 42; in the case where the generator you provided is used
>
> Aren't expr and expr_1 exactly the same?
Exactly the same, yes.
>> How this helps is that as phoenix expressions are being built, the
>> phoenix generator will ensure that all the nodes are held by-value.
>> There will never be a need for the user to deep_copy phoenix expressions
>> explicitly -- it's done piecemeal by phoenix. So function<> is passed an
>> object that does not need to be deep-copied.
>
> I see this difference now and understand the reasons behind your suggestion.
> Thanks for the explanation,
No problem.
-- Eric Niebler Boost Consulting www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk