Boost logo

Boost :

Subject: Re: [boost] [Boost.Lambda] Some new features are suggested: return, iterating yield, & local var
From: Huang Huan (mr.huanghuan_at_[hidden])
Date: 2012-01-03 23:05:37


Yes, Boost.Phoenix do a lot forward in unname function.
Unfortunately the presented features are not found in it.

2012/1/4 Mathias Gaunard <mathias.gaunard_at_[hidden]>
> return is hard to implement, since each expression is building its own
expression, so you need to forward it along the whole chain.
> Exceptions could also be used, but it's not very nice.

return is the most usefull part of function. I'm working on the implement,
it's approved work with no exception for return. The architect is defferent
from the lambda, I think the phoenix is also .
The final functional call is wrapped, and create a heap/stack like
workspace. It will support restore for yielding calls.
and yielding & local var are also involved in the return architect.

> Boost.Phoenix provides local variables using let/in syntax.

let(_a = 1)[...]
I think the let syntx is a worse way, and you may make some mistak of my
way. The let syntx is quite different from the C++ style, and _a ... _z are
limited.
I have implement the major part of my way, and some syntax have changed as
below:

// this macro is define in the lib define, use local_var_name<int id>
#define var_name(x) local_var_name<__LINE__> x;
// example begin here
struct A {
    A() {};
    A(char ch) {};
};

var_name(x); // just predefine the name in no type for lambda using.
var_name(y); // one single line for one var_name, the macro could be
redefined add some unuse code for unique line protect.
var_name(z);
(
    (
        // declaring use local_var, scope begin here
        local_var<A> (x) , // default construct A::A()
        local_var<A> (y) ('a') , // construct<A>('a') A::A(char)
        local_var<A> (z) (x) , // copy construct A::A(A const&)
        x = y // assignment
A::operator=(A const&)
    ),
    (
        x,y,z, // error, out of scope
    )
)
p.s.
1. the phoenix omitted the different way of construct/copy/assignment.
2. free style identifier name, better for code reader.

Actually I have rewrote lambda, it support return/yielding, most operators,
part of local var, without bind. I want to join the dev of Boost.Phoenix,
if can how?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk