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-Thread: 103376,c0d427d5f4af20f8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!newsfeed.arcor.de!news.arcor.de!not-for-mail Date: Tue, 13 Sep 2005 21:23:22 +0200 From: Georg Bauhaus Organization: future apps GmbH User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050718 Debian/1.7.8-1sarge1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: generics in Ada 83 References: <1126617980.932226.320710@g43g2000cwa.googlegroups.com> <4326d46b$0$27543$9b4e6d93@newsread4.arcor-online.net> <1126628739.232995.12460@g47g2000cwa.googlegroups.com> In-Reply-To: <1126628739.232995.12460@g47g2000cwa.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4327272a$0$27561$9b4e6d93@newsread4.arcor-online.net> NNTP-Posting-Date: 13 Sep 2005 21:23:22 MEST NNTP-Posting-Host: 2ac4d296.newsread4.arcor-online.net X-Trace: DXC=f641M:=P9Ihe`BX@Z?dZ]MOidU X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4624 Date: 2005-09-13T21:23:22+02:00 List-Id: REH wrote: > Georg Bauhaus wrote: > >>REH wrote: >> >> >>>generic >>> type X is private; >>> with procedure Y(Z : in X); >>>package Foo; >>> >>>I want to define a default for Y, but how can I without knowing X? >> >>Can you make generic stubs? > > > Can you do that in '83? I tried but I kept getting compiler errors. > Something like this may work. Unless I misunderstand your problem, i.e.. The generic package Stubs.X_Operations provides default null procedures for any private type X. You can use these operations as default values when instantiating Foo. generic type X is private; with procedure Y(Z : in X) is <>; -- lots of others package Foo is end Foo; with Stubs; with Foo; package Op_Maker is type Some_Type is record data: Natural; end record; type Some_Other_Type is record data: Character; end record; package Some_Operations is new Stubs.X_Operations(X => Some_Type); package Some_More_Operations is new Stubs.X_Operations(X => Some_Other_Type); use Some_Operations, Some_More_Operations; package A_Foo is new Foo(Some_Type); package Another_Foo is new Foo(Some_Other_Type); end Op_Maker; package Stubs is generic type X is private; package X_Operations is -- null procedures procedure Y(Z: in X); procedure Y2(U, V: in X); end X_Operations; end Stubs; package body Stubs is package body X_Operations is procedure Y(Z: in X) is begin null; end Y; procedure Y2(U, V: in X) is begin null; end Y2; end X_Operations; end Stubs;