From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Implementing Memorize
Date: Wed, 22 Oct 2003 19:41:56 +0000 (UTC)
Date: 2003-10-22T19:41:56+00:00 [thread overview]
Message-ID: <slrnbpdnc4.h2s.lutz@belenus.iks-jena.de> (raw)
In-Reply-To: pe5dpvkjj2p8aentvutrhu2qsre5q84fjg@4ax.com
* Dmitry A Kazakov wrote:
><lutz@iks-jena.de> wrote:
>>* Dmitry A Kazakov wrote:
>>> Solution depends on how exposed should be the context used to store
>>> results:
>>>
>>> 1. Completely hidden (allocated upon elaboration of the body)
>>> 2. Partially exposed as a generic parameter of the compilation unit
>>> 3. Fully exposed as a parameter of the subprogram
>>
>>It's more or less irrelevant.
>
> You have to choose an abstraction first. For instance for (1), a
> generic variant could be:
>
> generic
> type Argument_Type is private;
> type Parameter_Type is private;
> with function Evaluate (X : Argument_Type; N : Parameter_Type)
> return Argument_Type;
> function Evaluate_With_Side_Effects
> (X : Argument_Type; N : Parameter_Type)
> return Argument_Type;
>
> function Evaluate_With_Side_Effects
> (X : Argument_Type; N : Parameter_Type)
> return Argument_Type is
> begin
> if not <X & N already evaluated> then
> <store> Evaluate (X, N);
> end if;
> return <cached>;
> end Evaluate_With_Side_Effects;
In this case I have reference Evaluate_With_Side_Effects from Evaluate. How
can I implement this?
> What you wrote is also (1), but on the basis of a tagged type.
> Theoretically one could also use a discriminated type, to complete the
> list of opportunities.
This does not solve the problem of recursion.
> precise if the original values were known. The solution here was (3) +
> keeping track of original value changes.
Understood, but I didn't grasp how to prepare the Evaluate function for this
usage.
next prev parent reply other threads:[~2003-10-22 19:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-22 9:28 Implementing Memorize christoph.grein
2003-10-22 10:32 ` Lutz Donnerhacke
2003-10-22 10:48 ` Marius Amado Alves
2003-10-22 11:07 ` Lutz Donnerhacke
2003-10-22 11:33 ` Lutz Donnerhacke
2003-10-22 11:56 ` Lutz Donnerhacke
2003-10-22 12:29 ` Marius Amado Alves
2003-10-22 12:52 ` Lutz Donnerhacke
2003-10-22 13:42 ` Marius Amado Alves
2003-10-22 12:08 ` Dmitry A. Kazakov
2003-10-22 12:10 ` Lutz Donnerhacke
2003-10-22 15:23 ` Dmitry A. Kazakov
2003-10-22 19:41 ` Lutz Donnerhacke [this message]
2003-10-23 14:36 ` Dmitry A. Kazakov
2003-10-22 19:29 ` Robert I. Eachus
2003-10-22 19:44 ` Lutz Donnerhacke
-- strict thread matches above, loose matches on Subject: below --
2003-10-22 8:52 Lutz Donnerhacke
2003-10-22 15:00 ` Frank J. Lhota
2003-10-22 17:03 ` tmoran
2003-10-23 0:25 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox