commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <>
Subject [lang] Proposal for *NEXT* version
Date Thu, 03 Oct 2002 14:40:57 GMT
The Avalon team has learned how the language features of C# can help us
write better and more intelligent software.  However, since none of us
really has the money or inclination to completely tie ourselves to C#
or M$, we want to add language features in a Java way.

We threw together a way to generate Delegates.  A delegate is like a
method pointer, but it is also able to be treated like an Object.  The
benefit of this is that we can pass in the delegate to a method, and
change the behavior of that method substantially.

The perfect example where this pays off is with Intelligent Agent
design.  The Intelligent Agent is the building block of artificial
intelligence.  There are four or five basic algorithms for searching
through a problem space to find the best solution.  These algorithms
require you to pass in functions.  Delegates make all this possible,
without forcing the original class to have the same name.  For example:

interface NewComparator
     int compare( Object orig, Object other );

class ComparitorHeaven
     public int compareClassName( Object orig, Object other )
     { /* implementation */ }

     public int compareEquals( Object orig, Object other )
     { /* implementation */ }

With the two declarations above, I can write a search algorithm
like this:

public Object findBestObject( String method )
     ComparatorHeaven ch = new ComparatorHeaven;

     NewComparator checker =
        (NewComparator) Delagate.newDelagate( ch, method );

     Iterator it = m_myList.iterator();
     Object prev =;

     while( it.hasNext() )
         Object curr =;
         int preference = curr, prev );

         prev = curr;
         // perform actual decisions based on preference

We have some initial stuff checked in to Excalibur Util.
When we are done shaping it up, we would like to give it
to Commons Lang.  I realize you are getting ready to make
a release, which is why I don't want to push it for this
release.  What are y'alls thoughts?


"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message