You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Matt Munz <mm...@apelon.com> on 2003/09/22 22:35:22 UTC

[functor] Uses for Functors

Hi all,

  After reading "Blocks in Java", I'm pretty sure that Functors/closures are useful in certain instances.  I'm unfamiliar with the topic, however, and would like to gain a sense of in what scenarios they are best used.  In the use of collections / iterators, and in the serialization of algorithms (command pattern), the applicaton of Functors seems clear to me. Are there other common application areas?

  For example, what about event mechanisms?  Some languages use method pointers for this purpose.  Is there any sense in using Functors as event listeners?  I'm considering making a sort of universal adapter that would adapt a given functor to any of the event listener interfaces.  Does this make sense?  Has anyone tried using (java) Functors in an event-based system (GUI)?

  Additionally, what about combining Functors with reflection?  To invoke a method using reflection, one needs the object to act on and the name of the method to invoke.  This state can be stored in a proxy object, but perhaps a Functor / closure is a good choice for this?  Doing so would allow any object to be adapted to a (set of) Functor(s) at Runtime.  Similarly, interception, logging, etc., could be provided by a chain of Functors.

  I hope my questions aren't too newbieish ;)  Thanks for creating an interesting project.

  BTW, I origionally sent this message to commons-user, but got no response.

  - Matt Munz
    mmunz@apelon.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [functor] Uses for Functors

Posted by Stephen Colebourne <sc...@btopenworld.com>.
[functors] grew partially from the four functors in [collections],
Predicate, Closure, Factory and Transformer. (Although you can argue whether
these are true functors...)

Thus you could look at [collections] to see how these classes are used
there.

Stephen

----- Original Message -----
From: "Matt Munz" <mm...@apelon.com>
  After reading "Blocks in Java", I'm pretty sure that Functors/closures are
useful in certain instances.  I'm unfamiliar with the topic, however, and
would like to gain a sense of in what scenarios they are best used.  In the
use of collections / iterators, and in the serialization of algorithms
(command pattern), the applicaton of Functors seems clear to me. Are there
other common application areas?

  For example, what about event mechanisms?  Some languages use method
pointers for this purpose.  Is there any sense in using Functors as event
listeners?  I'm considering making a sort of universal adapter that would
adapt a given functor to any of the event listener interfaces.  Does this
make sense?  Has anyone tried using (java) Functors in an event-based system
(GUI)?

  Additionally, what about combining Functors with reflection?  To invoke a
method using reflection, one needs the object to act on and the name of the
method to invoke.  This state can be stored in a proxy object, but perhaps a
Functor / closure is a good choice for this?  Doing so would allow any
object to be adapted to a (set of) Functor(s) at Runtime.  Similarly,
interception, logging, etc., could be provided by a chain of Functors.

  I hope my questions aren't too newbieish ;)  Thanks for creating an
interesting project.

  BTW, I origionally sent this message to commons-user, but got no response.

  - Matt Munz
    mmunz@apelon.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org



Re: [functor] Uses for Functors

Posted by Stephen Colebourne <sc...@btopenworld.com>.
[functors] grew partially from the four functors in [collections],
Predicate, Closure, Factory and Transformer. (Although you can argue whether
these are true functors...)

Thus you could look at [collections] to see how these classes are used
there.

Stephen

----- Original Message -----
From: "Matt Munz" <mm...@apelon.com>
  After reading "Blocks in Java", I'm pretty sure that Functors/closures are
useful in certain instances.  I'm unfamiliar with the topic, however, and
would like to gain a sense of in what scenarios they are best used.  In the
use of collections / iterators, and in the serialization of algorithms
(command pattern), the applicaton of Functors seems clear to me. Are there
other common application areas?

  For example, what about event mechanisms?  Some languages use method
pointers for this purpose.  Is there any sense in using Functors as event
listeners?  I'm considering making a sort of universal adapter that would
adapt a given functor to any of the event listener interfaces.  Does this
make sense?  Has anyone tried using (java) Functors in an event-based system
(GUI)?

  Additionally, what about combining Functors with reflection?  To invoke a
method using reflection, one needs the object to act on and the name of the
method to invoke.  This state can be stored in a proxy object, but perhaps a
Functor / closure is a good choice for this?  Doing so would allow any
object to be adapted to a (set of) Functor(s) at Runtime.  Similarly,
interception, logging, etc., could be provided by a chain of Functors.

  I hope my questions aren't too newbieish ;)  Thanks for creating an
interesting project.

  BTW, I origionally sent this message to commons-user, but got no response.

  - Matt Munz
    mmunz@apelon.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org