Re: Porting to Java using Garden Point Compiler
----boundary-LibPST-iamunique-1748835633_-_-
Content-type: text/plain
Well, OK. I admit my previous solution was pretty much an off-the-wall
extreme OO solution with a bad interface. But, how about the following?
This solution is identical to the traditional way of passing a
function, and
is a better solution than my previous one. Here is the server:
=====================================================
MODULE NumericalProcessor;
IMPORT Math;
TYPE
Function* = POINTER TO ABSTRACT RECORD END;
PROCEDURE (f: Function) ValueOf* (x: REAL): REAL, NEW, ABSTRACT;
PROCEDURE Area* (f: Function; min, max, tol: REAL): REAL;
BEGIN
RETURN f.ValueOf (min) + f.ValueOf (max)
END Area;
END NumericalProcessor.
=====================================================
And here is the client.
=====================================================
MODULE NumericalApplication;
IMPORT NumericalProcessor, Math, StdLog;
TYPE
MyFunction = POINTER TO RECORD (NumericalProcessor.Function) END;
PROCEDURE (f: MyFunction) ValueOf (x: REAL): REAL;
BEGIN
RETURN x * x
END ValueOf;
PROCEDURE Do*;
VAR
f: MyFunction;
BEGIN
NEW(f);
StdLog.Ln;
StdLog.Real( NumericalProcessor.Area(f, 3, 4, 0.001));
StdLog.Ln
END Do;
END NumericalApplication.
=====================================================
Still, the mechanism is inheritance. This is _so_ close to the
traditional
way of passing a function, that porting a library should be fairly
mechanical.
My point is that procedure types are redundant, and it is the spirit of
Oberon
to not have more than one way to accomplish a task. There was even
a battle to include the FOR statement in the language because it is not
necessary as long as you have a WHILE. I also agree with Skulski's
devil's-advocate comment that function variables should be at a lower
level and only used to communicate with platform-specific routines. I
still maintain that high-level applications like numerical libraries
should
be packaged similarly to the above client/server system and that
procedure
parameters should not be in the language definition.
Cheers,
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 1:40 PM, Rex Couture wrote:
> ??? Thanks for clarifying how it can be done, but I'm with
> Wojtek Skulski on this one. First, it is much longer than my example,
> and therefore harder to read.
>
> More importantly, in your example I had a real problem
> figuring out that procedure Area used procedure ValueOf. This crucial
> information is not presented in the interface--you have to look inside
> the procedure. In my example, the procedural variable is clearly
> passed to the function (i.e., procedure), and this fact can be seen
> from a glance at the parameters. My example is also type-safe and
> robust.
>
> I'm not sure we're making any progress with fancy programming.
>
> Sincerely,
> Rex Couture
--------------------------------------------
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-1748835633_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFdlbGwsIE9LLiBJIGFkbWl0IG15IHByZXZpb3Vz
IHNvbHV0aW9uIHdhcyBwcmV0dHkgbXVjaCBhbiBvZmYtdGhlLXdhbGxccGFyDQpleHRyZW1lIE9P
IHNvbHV0aW9uIHdpdGggYSBiYWQgaW50ZXJmYWNlLiBCdXQsIGhvdyBhYm91dCB0aGUgZm9sbG93
aW5nP1x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dG8gdGhlIG1haWxpbmcgbGlzdC4gVGhhdCB3YXksIHRoZSBsaXN0IHNlcnZlciB3
aWxsIHJlY29nbml6ZSB5b3UgYXMgc3Vic2NyaWJlciBhbmQgZm9yd2FyZCB5b3VyIHBvc3Rpbmcg
aW1tZWRpYXRlbHksIHdpdGhvdXQgY3JlYXRpbmcgYW55IG92ZXJoZWFkLlxwYXINClxwYXINCmIp
IElmLCBmb3Igc29tZSByZWFzb24sIHlvdSBjYW5ub3QgcG9zdCBmcm9tIHRoZSBhZGRyZXNzLCBi
eSB3aGljaCB5b3UgYXJlIHN1YnNjcmliZWQsIHlvdXIgbWVzc2FnZSB3aWxsIGJlIG1vZGVyYXRl
ZCB0byBhdm9pZCBzcGFtLiBQbGVhc2UgdW5kZXJzdGFuZCB0aGF0IG1vZGVyYXRpb24gd2lsbCBv
ZnRlbiBjYXVzZSBzb21lIGRlbGF5LCBpbiBwYXJ0aWN1bGFyIG92ZXIgd2Vla2VuZHMgb3IgaG9s
eWRheXMuXHBhcg0KfQ==
----boundary-LibPST-iamunique-1748835633_-_---
Received on Thu Nov 18 2004 - 00:32:19 UTC
This archive was generated by hypermail 2.3.0
: Thu Sep 26 2013 - 06:28:31 UTC