On Jan 17, 2008 1:19 PM, Attila Szegedi <[EMAIL PROTECTED]> wrote:
> Functions being first-class objects in most of languages we discuss
> here, their usual implementation is to generate an on-the-fly class,
> i.e. "class 0a9cee3478 implements Function { ... }" and instantiate
> exactly one instance of it to pass around as said first-class object.
>
> If we want to have our functions to be garbage collectibe with a
> single function granularity, then the class for each one of them needs
> to be loaded in its own class loader that only loads that class and
> nothing else . And that's what feels unnecessarily convoluted (having
> one classloader per class) and raises the requirement for some
> "lightweight method objects".
One thing I have considered is aggregating all these
closures/lambda/etc in a compilation unit as static methods on a
single class. This means that you amortise the cost of a classloader
over several methods. Instances of the function object delegate to the
static method. The cost is, obviously, delayed GC of the "mothership"
class. Of course, if you can dynamically create new functions this
won't help.
John Wilson
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---