From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d74d61525ce986e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-22 05:07:37 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Implementing Memorize Date: Wed, 22 Oct 2003 14:08:32 +0200 Message-ID: References: NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1066824456 30347247 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:1409 Date: 2003-10-22T14:08:32+02:00 List-Id: On Wed, 22 Oct 2003 11:07:43 +0000 (UTC), Lutz Donnerhacke wrote: >* Marius Amado Alves wrote: >>> What's the correct way to implement it? >> >> Maybe with an access-to-subprogram type. > >Of course this works. But I'm looking for a generic version. > >> What problem are your trying to solve? > >Calculating Fibbonacci numbers recursivly is easy but braindead. Languages >with access to the symbol table at execution time are able to change the the >reccuring call with a memorize wrapper which returns already computed values >immediatly instead of recalculating them. In the referenced article I wrote >an C-Implementation of such a wrapper. Now I'm looking for a more elegant >version in Ada. 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 --- Regards, Dmitry Kazakov www.dmitry-kazakov.de