[2049] in java-interest
Re: method/fn ptrs?
daemon@ATHENA.MIT.EDU (Smiljan Grmek - KSI ZGB)
Fri Sep 22 12:34:29 1995
Date: Fri, 22 Sep 1995 15:10:52 +0200 (MET DST)
From: Smiljan Grmek - KSI ZGB <sgrmek@public.srce.hr>
To: Jonathan Payne <jpayne@starwave.com>
Cc: Sami.Shaio@Eng.Sun.COM, java-interest@java.Eng.Sun.COM, fgreco@lehman.com
In-Reply-To: <9509210132.AA23020@flim.starwave.com>
On Wed, 20 Sep 1995, Jonathan Payne wrote:
> The language needs method pointers. Life sucks without them.
Nope, *we* need method pointers, the language can express anything. The
design decision was *no pointers* - and correctly so. Security
considerations are primary because that may be the key quality of the
system (not just the language but the interpreter too).
What you do is turn the problem (an your thinking - which got into
C++/Smalltalk rut) around:
- encode the action as data and have a switch statement, or (in order
to be able to dynamically add new methods)
- create a KeyResponder class (abstract) and encode responses/actions in
RespondToKey method for each subclass, then form an array of
KeyResponder objects where each one is from the appropriate subclass.
A mixture of above techniques will get you a fairly flexible program. The
point is that there is *no* way to invoke a method not known (or at least
declared in an Interface) at compile time - an equivalent to Smalltalk
'perform:' about which there was intense discussion before.
Regards, Smi
Smiljan Grmek
KSI Zagreb
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com