|
Boost : |
Subject: [boost] [GSoC][Phoenix3] Regarding mutability of arguments passed to phoenix expressions
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2010-04-27 15:49:01
Regarding arguments to phoenix expressions there are two possibilities.
The first is: Arguments are mutable. The current phoenix is implemented to be
able to this.
Example:
int i( 1 );
( ++phoenix::arg_names::arg1 )( i );
The result of ++phoenix::arg_names::arg1 will be 2, i will have the value 2
after the expression is evaluated.
The other approach would follow a more functional programming style as the
data will not be mutable
int i( 1 );
[1] ( ++phoenix::arg_names::arg1 )( i );
[2] ( ++phoenix::arg_names::arg1 + phoenix::arg_names::arg1 )( i );
The result of [1] will be 2, however i does not get changed (it remains to be
1).
The result of [2] will be 3. i still unchanged.
This example would be working "out-of-the-box" with the current prototypes.
To get the mutability back into phoenix i propose the use of phoenix::ref.
I favor the second approach. However, this would break API compatibility
between the existing implementation.
The question i want to ask the current and prospective users if it feasible to
break your existing code? Is there a lot of existing code depending on this
behaviour? Does it make sense to break code in such a way?
Regards,
Thomas
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk