Using closures for specifying default parameter values in Groovy
===

Let's consider the next function:


    def generateUniqueIdent(String text, uniqueSuffix = {uid -> String.valueOf(uid)}) {
       doSomething(text) + uniqueSuffix()
    }

Now, when I try the next modification:

    def generateUniqueIdent(String text, uniqueSuffix = { hash(text) }) {
       doSomething(text) + uniqueSuffix()
    }        

..I got the next error:

> | Error Fatal error during compilation
> org.apache.tools.ant.BuildException: BUG! exception in phase 'class
> generation' in source unit 'some path here' tried to get a variable
> with the name **text** as stack variable, but a variable with this
> name was not created (Use --stacktrace to see the full trace)

At the same time, if I try to use the name `text` as a parameter of the closure:


    def generateUniqueIdent(String text, uniqueSuffix = {text -> hash(text) }) {
       doSomething(text) + uniqueSuffix(text)
    }     

..then I got another error:

> The current scope already contains a variable of the name **text**

The question is: can I somehow get access to other parameters from a closure, which is assigned as a default value to one of function parameters?

If no, then, why can't I use the same name as one of function parameters has inside the described closure?