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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: I'm facing an issue with: call to abstract procedure must be dispatching Date: Tue, 8 Dec 2015 10:30:56 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <8bc7fd76-f00a-4eea-9715-470af028fc84@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 8 Dec 2015 17:28:30 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="caa759af2a9c666aec02942f6fe5abd6"; logging-data="19902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180W3St1YossJucH/IBt5A/eXwpvmGFZUg=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <8bc7fd76-f00a-4eea-9715-470af028fc84@googlegroups.com> Cancel-Lock: sha1:AjaQ7HciPSdTQPTfjiUh7byJPyI= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:28711 Date: 2015-12-08T10:30:56-07:00 List-Id: On 12/08/2015 09:45 AM, Serge Robyns wrote: > > I've been trying to get my head around a way to create a solution where the storage method can be changed. In your approach, IIUC, you would change the Insert procedures for each of the types to change the storage method. You are on the right track, but are confused by the added complexity of using programming by extension. The typical way to do this in Ada is something like with T1_Ops; with T2_Ops; ... package Storage is procedure Put (Item : in T1_Ops.T1); procedure Put (Item : in T2_Ops.T2); ... end Storage; The bodies of the Put procedures correspond to your Insert procedures. (You can call them Insert, too, if you like, but I once heard it asserted that a correctly designed Ada program has 90% of its operations named Put or Get.) This is then used as with Storage; ... Storage.Put (Item => Current_Item); which is the same regardless of the type of the item being stored. To change the storage method, you change the body of Storage. Note that programming by extension is neither necessary nor desirable for this. -- Jeff Carter "Your mother was a hamster and your father smelt of elderberries." Monty Python & the Holy Grail 06