Boost logo

Boost :

From: Gary Powell (powellg_at_[hidden])
Date: 2002-03-18 12:26:29


> > I haven't look at any of the technical issues, but from a purely
> > esthetic view I prefer the familiar, explicit "lambda(x, y, x + y)".

Also I might add, that with _1 being a typedef, you can have "x", "y", "z"
instead if you prefer. Then writing a fn "lambda" to look like the above is
pretty trivial.

(This is not to say that FACT and LL are equivalent, but that the simpler
things in FACT can be simulated in LL, and probably vise versa.)

(Warning untested code!)

namespace LL_FACT {

typedef boost::lambda::placeholder1_type& x = free1;
typedef boost::lambda::placeholder1_type& y = free2;

template<class BinderArgs>
boost::lambda::lambda_functor<BinderArgs> &
lambda(boost::lambda::placeholder1_type&,
       boost::lambda::placeholder1_type&,
       boost::lambda<BinderArgs> &lfn)
{ return lfn; }

}
  using LL::FACT x,y;
  for_each(a.begin(), a.end(), LL_FACT::lambda(x,y, x+y)(1) );

(Note: The above does not check the order of the placeholder arguments, the
way FACT does, nor does if verify that the lambda function even uses the
same set of place holder arguments that are stated in args 1, & 2.) This
could be done but not in an email message code.

  ie.
   for_each(a.begin(), a.end(), LL_FACT::(lambda(_1,y)(x+_2) );

would compile. (IMO it shouldn't)

  Anyway Jaakko and I have looked at FACT! and J.Striegnitz has looked at
Lambda, and while we differ on some of the syntax issues we agree that C++
needs a functional languge.

  Future work could include a real "lambda" function specifier if there is a
need.

  We've also looked at integration with PETE. (Whose development appears to
be on hold.) But so far haven't done anything more than play around with it.

  Yours,
  -Gary-


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