$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Bjorn.Karlsson_at_[hidden]
Date: 2002-03-25 10:59:16
> From: Asger Alstrup Nielsen [mailto:alstrup_at_[hidden]]
> It might help to illustrate one of my points by writing the 
> following as
> an anonymous lambda expression:
[snip]
 
> My initial try to write this with LL is this:
> 
> int j;
> std::for_each(v.begin(), v.end(), 
> 	switch_statement(_1,
> 		case_statement<0>(_1 + 1),
> 		case_statement<1>(try_catch( 
> 						bar(_1 + 3),
> 					catch_all(-1)
> 					)
> 		),
> 		default_statement(if_then_else(_1 < 10, 
> 						1,
> 						( j = 1, 
> 						  while_statement(_1 <
> 100, 
> 							(j += _1, 
> 							 i /= 2
> 							) 
> 						), 
> 						j)
> 					)
> 		)
> 	);
> );
> 
> I can't check it because I'm stuck with VC6, but there is at least one
> error in the above. Can you spot it?
> 
> I do not think this style of programming is something to encourage.
Agreed, but then again, you could have opted to have your first version of
foo look like this:
void l(int i,int& j) {
  while (i>100) {j+=i,i>>=1;}
}
int foo(int i) {
  try {
    int j=42;
    return i==0?i+1:(i==1?bar(i+3):(i<10?i=1,i:j=i,l(i,j),j));
  }
  catch(...) {return -1;}
}
My point? 
Expressive power brought by a library, or the language itself, implies a
certain level of responsibility from its clients. Are there no relevant uses
for these high-geared lambda expressions? I think there are, and that's what
I feel is pertinent to the discussion.
  
> I much prefer the basic lambda library with only basic expression
> support, assignment, scoping and boost::function interaction.
Actually, I do to, but not to the degree that I feel the library should not
be accepted because it includes other features (which, I might add, are
features that I personally don't yet understand the full implications of). 
[Note: I tried to include the same bug, did you spot it? ;-)]
Bjorn Karlsson