On Aug 14, 2011, at 1:50 PM, John Freeman wrote:

> On 8/12/11 5:26 PM, Douglas Gregor wrote:
>> +/// LambdaDecl - Represents a C++0x lambda expression.
>> +class LambdaDecl : public Decl, public DeclContext {
>> 
>> It would help if the comment here showed an example lambda expression, and 
>> pointed out the main pieces (capture list, body, etc.).
>> 
>> Please add more source-location information to LambdaDecl, so we have at 
>> least enough source-location information to implement getSourceRange() for 
>> LambdaDecl, covering the entire declaration. We'll need this source 
>> information for diagnostics and indexing.
>> 
>> +/// LambdaExpr - Adaptor class for mixing a LambdaDecl with expressions.
>> +class LambdaExpr : public Expr {
>> +  LambdaDecl *Lambda;
>> +
>> 
>> It's really not just an "adaptor", is it? It's the actual lambda expression. 
>> Please expand the comment with an example lambda expression. The commenting 
>> here is actually more important than for LambdaDecl, since lambdas are an 
>> expression in the language.
> 
> 
> Yeah, I'm still trying to figure out the LambdaDecl/LambdaExpr distinction 
> myself. I based it off of the BlockDecl/BlockExpr design. Here is my current 
> theory: LambdaExpr should be the AST node returned from 
> ParseLambdaExpression. It holds a LambdaDecl that contains all the 
> declarations related to the lambda expression: Captures, CXXMethodDecl, 
> CXXRecordDecl. Location information for the whole expression will be stored 
> in LambdaExpr. Components will have their location information stored in 
> their respective Captures, ParmVarDecls, Stmt, etc.
> 
> I'm starting to wonder, though, if we even need a LambdaDecl. Why not just 
> put everything in the LambdaExpr? I have not come across a need for a Decl or 
> DeclContext for lambdas, but I might have just not hit it yet.


Interesting. The reasons for BlockDecl that I can think of really don't apply 
to lambdas, because lambdas already have a Decl and DeclContext associated with 
them (the generated CXXMethodDecl). It would certainly feel simpler to just 
have a LambdaExpr.

        - Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to