[Tutor] An example of something extremely difficult to expres s in Java

Blake Winton bwinton@tor.dhs.org
Thu, 11 Apr 2002 09:46:39 -0400


* Karthik Gurumurthy <karthikg@aztec.soft.net> [020411 04:03]:
> i tried writing a command interface to encapsulate a method..i mean
> the way Runnable is...to accomodate a function object. i tried
> returning an ArrayList.  I did figure out that it is a little
> complicated.

I never thought it was that bad...
interface Command
{
    public Response execute( Request request );
}

interface Request {}
interface Response {}

Then you can make implementors of Request and Response, and stick
whatever data they want in them, and pass them to your implementors of
Command.  Just remember to cast them in your execute method...

> > Now try writing Danny differentiator function builder....
> where can i find this?

It should be in the list archives...

As another example of something that's nigh-impossible in Java, but easy
in Python, "eval/exec".  Executing arbitrary code entered by the user...
Okay, maybe it's not a good idea, but it's also nigh-impossible.  ;)

Later,
Blake.
-- 
  9:44am  up 29 days, 12:33,  2 users,  load average: 0.00, 0.00, 0.00