Re: C++: Implement code transformation in parser or tree

2006-11-12 Thread Mark Mitchell
Sohail Somani wrote: On Fri, 2006-11-10 at 19:46 -0800, Andrew Pinski wrote: On Fri, 2006-11-10 at 15:23 -0800, Sohail Somani wrote: Do you need new class types, or just an anonymous FUNCTION_DECL? Hi Mark, thanks for your reply. In general it would be a new class. If the lambda function

Re: C++: Implement code transformation in parser or tree

2006-11-12 Thread sohail
Yes they can in fact. So the object can outlive the scope. As I understand the lambda proposal, the lambda function may not refer to things that have gone out of scope. It can use *references* that have gone out of scope, but only if the referent is still in scope. Since the way that

Re: C++: Implement code transformation in parser or tree

2006-11-12 Thread sohail
Of course, all this is silly if nested functions carry around their lexical scope and can be returned. But I dont know that they do. A simple test case that would not invoke UB with n1968 lambda functions: #include stdio.h typedef void (*fn_t)(); void doinvoke(fn_t f) { f(); } fn_t

Re: C++: Implement code transformation in parser or tree

2006-11-12 Thread Gabriel Dos Reis
Mark Mitchell [EMAIL PROTECTED] writes: [...] | Also, it appears to me that there is something missing from N1958: there | is no discussion about what happens when you apply typeid to a lambda | function, or otherwise use it in a context that requires type_info. There still are some discussions

Re: C++: Implement code transformation in parser or tree

2006-11-12 Thread sohail
There still are some discussions going on (it is not alsways feasable to reflect all the discussions), especially with respect to callback, default policy and the like. [...] There is the discussion on callbacks. Are these discussions public? Is there a way to get archives? Thanks, Sohail

Re: C++: Implement code transformation in parser or tree

2006-11-12 Thread Gabriel Dos Reis
[EMAIL PROTECTED] writes: | There still are some discussions going on (it is not alsways feasable | to reflect all the discussions), especially with respect to callback, | default policy and the like. | | [...] | | There is the discussion on callbacks. | | Are these discussions public?

Re: C++: Implement code transformation in parser or tree

2006-11-12 Thread sohail
Quoting Gabriel Dos Reis [EMAIL PROTECTED]: [EMAIL PROTECTED] writes: | There is the discussion on callbacks. | | Are these discussions public? Most of them happened at the last C++ committee meetings in Berlin, Germany and Portland, Oregon). There must be some record on the EWG wiki, but I

Re: C++: Implement code transformation in parser or tree

2006-11-10 Thread Mark Mitchell
Sohail Somani wrote: struct __some_random_name { void operator()(int t){t++;} }; for_each(b,e,__some_random_name()); Would this require a new tree node like LAMBDA_FUNCTION or should the parser do the translation? In the latter case, no new nodes should be necessary (I think).

Re: C++: Implement code transformation in parser or tree

2006-11-10 Thread Sohail Somani
On Fri, 2006-11-10 at 14:47 -0800, Mark Mitchell wrote: Sohail Somani wrote: struct __some_random_name { void operator()(int t){t++;} }; for_each(b,e,__some_random_name()); Would this require a new tree node like LAMBDA_FUNCTION or should the parser do the translation?

Re: C++: Implement code transformation in parser or tree

2006-11-10 Thread Andrew Pinski
On Fri, 2006-11-10 at 15:23 -0800, Sohail Somani wrote: Do you need new class types, or just an anonymous FUNCTION_DECL? Hi Mark, thanks for your reply. In general it would be a new class. If the lambda function looks like: void myfunc() { int a; ...(int i1,int i2) extern (a)

Re: C++: Implement code transformation in parser or tree

2006-11-10 Thread Sohail Somani
On Fri, 2006-11-10 at 19:46 -0800, Andrew Pinski wrote: On Fri, 2006-11-10 at 15:23 -0800, Sohail Somani wrote: Do you need new class types, or just an anonymous FUNCTION_DECL? Hi Mark, thanks for your reply. In general it would be a new class. If the lambda function looks like:

C++: Implement code transformation in parser or tree

2006-11-07 Thread Sohail Somani
Hi, I'm trying to implement proposal n1968 in g++ which basically adds lambda functions to C++. The obvious way of implementing this is by a simple translation which generates a function object which is created where the lambda function is created. Something like: for_each(b,e,(int t){t++;});