Re: [groovy-dev] Bug or feature?
Am 01.04.2012 08:30, schrieb Russel Winder:
> I can't decide if this is a bug or a feature, hence the dev list rather
> than the user list. Given a tail recursive using a trampoline closure
> iterate:
>
> final factorial = { i -> iterate ( i , 1G ) }
> factorial ( n )
>
> works fine, but
>
> { i -> iterate ( i , 1G ) } ( n )
>
> fails with a message along the lines of:
>
> Caught: groovy.lang.MissingMethodException: No signature of method:
Factorial$_tailRecursive_closure2.call() is applicable for argument types: (java.lang.Integer,
Factorial$_tailRecursive_closure3) values: [100, Factorial$_tailRecursive_closure3 <at> d11151a]
> Possible solutions: any(), any(), dump(), grep(), find(), collect()
>
> which rather caught me by surprise. What is it about assigning and
> using an explicit reference to the object rather than just an implicit
> one?
I think this is a newline problem. I guess the script above is
incomplete and I also guess what happens is that the parser thinks the
block actually belongs to the line before. An example of this is:
def i=1
{}
Here the parser will assume, that the block belongs to the def and makes
this out of it: "def i=1 {}", which becomes "def i=1.call({})" and of
course then fails with a MissingMethodException similiar to above, about
not being able to do a call()
bye blackdrag
--
--
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email