jastrachan | 1 Apr 22:06 2005
Picon

Re: Access to names of closure formal parameters?


On 1 Apr 2005, at 20:59, Carl D. Burke wrote:
> I'm interested in looking at Groovy for specifying
> ontology and process information for a dialogue toolkit
> I've been writing. However, I've encountered an immediate
> stumbling block, which is that I can't seem to find
> where the names of closure parameters are stored.

They are stored in the AST, if that helps? We sometimes grab the AST of 
the code and analyse it. e.g. the SQL query helper can turn a closure 
into an SQL query, by walking the AST.

> I can get the types of the parameters easily enough,
> but that doesn't give me information I need when the
> relevant builder is executed. I can work around it by
> specifying a declared list of parameter names in addition
> to the actual parameter names in the closure, but that's
> both ugly and error-prone. Better to use the mechanism
> that already exists (if possible).
>
> I'm hoping that this is going to be simple, but I don't
> have the time to invest in learning the ins and outs of
> how Groovy is implemented. Any hints?

You could use named parameter passing in the builders to receive the 
parameter names & values as a Map?

James
-------
http://radio.weblogs.com/0112098/


Gmane