----boundary-LibPST-iamunique-649104225_-_-
Content-type: text/plain
Robert
Many thanks for an interesting example (especially that it gave me an opportunity to further study your excellent library; the excerpt from your message I'd like to take issue with, is appended).
However, it is now my turn to point out an unstated assumption in your design.
The assumption is that mathematically equivalent entities (the functions Cdf and Pdf) are represented in syntactically equivalent ways. In your case:
Variate = POINTER TO ABSTRACT RECORD
...
(rv: Variate) Cdf (x: REAL): REAL, NEW, EXTENSIBLE;
...
(rv: Variate) Pdf (x: REAL): REAL, NEW, EXTENSIBLE;
...
END;
A software implementation ought to (I would say, must) also reflect practical considerations (usage etc.).
In your specific case, you pointed it out yourself that there are great differences between Cdf and Pdf in that respect.
I would implement your Variate as follows:
Variate = POINTER TO ABSTRACT RECORD
(rv: Variate) Pdf (): Function, NEW, ABSTRACT; (* necessary *)
(rv: Variate) Cdf (VAR x: Function), NEW, EMPTY; (* unnecessary *)
...
END;
with
Function = POINTER TO ABSTRACT RECORD
(f: Function) Eval (x: REAL): REAL
END;
defined somewhere for general use.
Plus, I would provide an independent procedure:
PROCEDURE Cdf (v: Variate): Function;
or a non-extensible method:
(rv: Variate) DefaultCdf (): Function, NEW;
It would incorporate knowledge about special cases such as Exponential, as well as provide a default.
Separation of Cdf and Pdf from Variate is advantageous for reasons of flexibility (you will agree it is hard to predict all possible types of application problems).
The lack of symmetry between Cdf and Pdf reflects their (very) different usage.
A side remark: in a large class of problems I deal with, Pdf's are not available, so I would make Variate.Pdf an EMPTY method too.
To summarize, your statement about desirability of EXTENSIBLE methods does not, in my view, stand up to scrutiny, and is only valid within a somewhat narrow and somewhat inflexible implementation scheme you adopted.
Cheers
Fyodor
> >> So with this the argument for EXTENSIBLE procedures vanished and they are
> >> a matter of personal style as were EXTENSIBLE RECORDs and Fjodor is right,
> >> both might - on the level of Component Pascal at least - be banned.
>
> I think there is a flaw in the above conclusions, resulting from an unstated assumption.
>
> People consider only what is NEEDED for correct function (usually using 'Initialisation' as an example.
> There is also the question of what is DESIRABLE for correct function.
>
> I give an example (taken from LibRandom, but there are many others).
> This implements an ABSTRACT type meant to represent a mathematical object called
> a Random Variate (or RV).
> These come in various flavours with names such as 'Normal', 'Exponential',
> and in millions of user specific flavours.
>
> They can be (mathematically) described in many different
> (but essentially equivalent) ways.
> Two of the most common (and useful) are called the 'Pdf' and the 'Cdf'.
>
> The ABSTRACT base type 'Variate' uses the (ABSTRACT) 'Pdf' to compute the 'Cdf'.
> When Variate is extended to, for example, Exponential,
> it is NECESSARY to implement the ABSTRACT base procedure Pdf,
> it is NOT NECESSARY to implement the EXTENSIBLE procedure Cdf.
>
> However, for the Exponential RV, Cdf has a very simple mathematical form and
> it is very easy and very desirable (vastly faster, more accurate, simpler)
> to reimplement Cdf as well.
>
> On the other hand, for user defined RV's, it may be very difficult, if not impossible,
> to reimplement Cdf directly, and depending on the application
> there may be no desire to use the Cdf much anyway,
> so run-time efficiency is secondary to minimising coding effort.
>
> The Component Pascal attribute EXTENSIBLE simply supports this 'optional' reimplementation;
> I don't see an equally simple alternative.
Powered by the E-mail PIM - Info Select - www.miclog.com
--------------------------------------------
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-649104225_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1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