----boundary-LibPST-iamunique-1983183523_-_-
Content-type: text/plain
With object-orientation, procedure types are redundant and should
be eliminated, IMHO. You should design your numerical processing
server as an abstract class, and specify to the client what your server
needs to provide its service. Namely it needs a function of one real
variable that returns a real value. You also specify the service your
module is to provide. Namely you will provide an integration function.
Here is your server:
=====================================================
MODULE NumericalProcessor;
IMPORT Math;
TYPE
NumProcessor* = POINTER TO ABSTRACT RECORD END;
PROCEDURE (n: NumProcessor) ValueOf* (x: REAL): REAL, NEW, ABSTRACT;
PROCEDURE (n: NumProcessor) Area* (min, max, tol: REAL): REAL, NEW;
BEGIN
RETURN n.ValueOf (min) + n.ValueOf (max)
END Area;
END NumericalProcessor.
=====================================================
To use your service, the client is obliged to implement the function
that you require. Inheritance is the mechanism. Here is a client:
=====================================================
MODULE NumericalApplication;
IMPORT NumericalProcessor, Math, StdLog;
TYPE
MyApplication* = POINTER TO RECORD (NumericalProcessor.NumProcessor)
END;
PROCEDURE (m: MyApplication) ValueOf* (x: REAL): REAL;
BEGIN
RETURN x * x
END ValueOf;
PROCEDURE Do*;
VAR
m: MyApplication;
BEGIN
NEW(m);
StdLog.Ln;
StdLog.Real( m.Area(3, 4, 0.001));
StdLog.Ln
END Do;
END NumericalApplication.
=====================================================
The server "programs to the abstraction". Type checking of the parameter
list is strong. The interface of the server module is crisp. I think it
is a big
conceptual improvement over procedure types.
Stan
J. Stanley Warford
Professor of Computer Science
Pepperdine University
Malibu, CA 90263
Stan.Warford{([at]})nowhere.xy
310-506-4332
On Nov 17, 2004, at 10:21 AM, skulski{([at]})nowhere.xy
> How about the following. I typed this right now so not sure if this is
> all
> correct, but gives you a flavor. IMHO this is an illustration why
> procedure types should *not* be dropped from the language. Purists will
> say procedure types are not needed, but then purists probably have
> never
> calculated any integrals anyway. The bottom line: do not break away
> from
> 50 years of tradition unless you can convincingly argue there is no
> other
> way. Or, if you break away for puristic reasons, then do not complain
> people do not want to use the language anymore.
>
> MODULE Integrand;
> TYPE
> FnType * = POINTER TO RECORD
> END;
> PROCEDURE (f: FnType) Calculate * (x: REAL), NEW;
> BEGIN
> RETURN x*x (*just an example*)
> END Calculate;
> END Integrand.
>
> MODULE Integrate;
> IMPORT Integrand;
>
> PROCEDURE Integ (
> func: Integrand.FnType;
> xMin, xMax, tol: REAL
> ): REAL;
> BEGIN
> (* call func like this: func.Calculate (x) *)
> END Integrate;
>
>> If procedure types are obsolete, how do I write a library
>> procedure that *requires* a functional parameter? Example:
>>
>> TYPE
>> FnType = FUNCTION(x: REAL): REAL;
>>
>> FUNCTION integral( integrand: FnType; xMin, xMax, tol: REAL): REAL
>>
>> Sincerely,
>> Rex Couture, Ph. D.
>> Dept. of Earth and Planetary Sciences
>> Campus Box 1169
>> Washington University in St. Louis
>> 1 Brookings Dr.
>> St. Louis MO 63130
>>
>> Voice: (314) 935-4194
>> Fax: (314) 935-7361
>> rex{([at]})nowhere.xy--------------------------------------------
To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
blackbox-request{([at]})nowhere.xy
To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.
Send any problem reports or questions related to this email list to the list owner at
owner-blackbox{([at]})nowhere.xy
Current posting policy:
a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.
b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.
----boundary-LibPST-iamunique-1983183523_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5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