#1308 Closures param names are not available at runtime

tonsky Thu 11 Nov 2010

Are there any reasons why closures param names are replaced by a, b etc at runtime?

>>> f := |Int x, Int y -> Int| { x+y }
>>> f.params.map { it.name }
["a", "b"]

Expected:

["x", "y"]

brian Thu 11 Nov 2010

Promoted to ticket #1308 and assigned to brian

The closure is using default Func.params implementation. But I am pretty sure the parameters are actually already in the fcode, so should be easy to expose them. I will take a look.

Also look to ensure that Func.bind parameter names remain available.

brian Mon 3 Jan 2011

Ticket resolved in 1.0.57

I spend a while yesterday changing all function signatures to include parameter names and got it all working. But it created some weird issues where function types were equal could have different signatures. So after sleeping on it, I decided to fix this locally to the JVM runtime by just reflecting the doCall parameter names.

Also while I was in this code, I optimized closure constructors to create params list lazily. This seems to have a noticeable impact on speed in some of my tests due to how heavily closures are used.

changeset

DanielFath Mon 3 Jan 2011

Positive or negative impact?

brian Mon 3 Jan 2011

Positive or negative impact?

You mean performance? Positive of course or I wouldn't do it :-)

Login or Signup to reply.