Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-01-05 10:23:05


From: "Joel de Guzman" <djowel_at_[hidden]>
> From: "Peter Dimov" <pdimov_at_[hidden]>
>
[...]
> > ref(x)(...) can mean two different things, both reasonable. One is to
simply
> > return x. The other is to return x(...). The convention we have adopted
so
> > far in bind and function is to treat ref as if ref(x)(...) returns
x(...).
> > This has nothing to do with spirit using bind, function, or lambda. It's
> > about the semantics of ref.
> >
> > In fact, if you use ref(b) as above, you now have no way to express the
> > other operation, make if_p store a reference to the function object:
> >
> > if_p(ref(f))
> > [
> > ]
> >
> > This is necessary when f has state or cannot be copied.
>
> Ok, I understand. Anyway, do you have a suggestion? Perhaps
> what I need then is a low-fat var(x) and val(x).
>
> Thoughts?

My thoughts with my "independent observer/low-tolerance library user" hat on
are:

* A good lambda library should already have a low-fat, low-dependency
var(x), something like

template<class E> struct basic_lambda_expression {}; // tag

template<class T> class var_expression: public basic_lambda_expression<
var_expression<T> >
{
public:

    typedef T & result_type;

// obvious implementation
};

* Two good lambda libraries sharing the same boost:: namespace will share
basic_lambda_expression<> and recognize each other's lambdas. ;-)


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