[1988] in java-interest
Re: method/fn ptrs?
daemon@ATHENA.MIT.EDU (Jonathan Payne)
Wed Sep 20 23:56:22 1995
Date: Wed, 20 Sep 1995 18:32:22 -0700
From: jpayne@starwave.com (Jonathan Payne)
To: Sami.Shaio@Eng.Sun.COM
Cc: java-interest@java.Eng.Sun.COM, fgreco@lehman.com
In-Reply-To: <199509202244.PAA16432@ruffles.Eng.Sun.COM> (Sami.Shaio@Eng.Sun.COM)
Hi Sami,
Nothing personal ... :-) but
Translation: Give it up!
Could you imagine implementing emacs-style keymaps in Java? You'd
have to implement a KeyAction subclass for each command you want to
bind to a key. And each one of those subclasses would probably make a
call to another object that implements all that commands, since they
would probably rather be all together.
It's also a problem for handling callbacks from GUI controls. Right
now we have to overload methods with the object making the callback,
and that sort sucks in a number of ways. What if you want slider1 to
call one routine and slider2 to call another? Now you have to switch
in the callback to see which one it is. What if you have a new kind
of GUI object that's making a callback. The only way to make that
work is to implement the new GUI to know who it's calling back, so
that it can explicitely call the right method that's defined in that
one class ...
The language needs method pointers. Life sucks without them.
> Date: Wed, 20 Sep 1995 15:44:35 -0700
> From: Sami.Shaio@Eng.Sun.COM (Sami Shaio)
> X-Sun-Charset: US-ASCII
> Sender: owner-java-interest@java.sun.com
> Precedence: bulk
> X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
> Content-Type: text
> Content-Length: 909
>
> There is no direct equivalent in Java. What you can do is create a
> class, for example Action, that has an execute method. You then
> have an array of Action objects which you can call execute on.
>
> --sami
>
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com