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!nx01.iad01.newshosting.com!newshosting.com!news-peer0-test!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: Martin Dowie Newsgroups: comp.lang.ada Subject: Re: generics in Ada 83 Date: Tue, 13 Sep 2005 16:41:53 +0000 (UTC) Organization: BT Openworld Message-ID: References: <1126617980.932226.320710@g43g2000cwa.googlegroups.com> <4326d73a$1_1@glkas0286.greenlnk.net> <1126629046.328151.40970@g47g2000cwa.googlegroups.com> NNTP-Posting-Host: host81-152-56-192.range81-152.btcentralplus.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com 1126629713 17938 81.152.56.192 (13 Sep 2005 16:41:53 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Tue, 13 Sep 2005 16:41:53 +0000 (UTC) In-Reply-To: <1126629046.328151.40970@g47g2000cwa.googlegroups.com> X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) Xref: g2news1.google.com comp.lang.ada:4616 Date: 2005-09-13T16:41:53+00:00 List-Id: REH wrote: > Martin Dowie wrote: > >>REH wrote: >> >>>Is there a way to define a default for the with'd procedure in the >>>following example in Ada 83: >>> >>>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? >>> >>>I have a generic package that has several with'd procedures, but >>>depending on what services the package provides are use, only a few of >>>the procedures may need to be defined. I'd like to just default the >>>unused ones to stubs. >> >>Same as Ada95: >> >>generic >> type X is private; >> with procedure Y (Z : X) is <>; >>package Foo is >>end Foo; >> >>Or do you mean you want the compiler to magically insert a 'null' procedure >>if there isn't a matching procedure Y for whatever type X happens to be? If >>that's the case you can't do that. There has to be some procedure (even one >>that's only 'begin null end;') for each type. >> >>Cheers >> >>-- Martin > > > defining it with a box won't work. There would have to a procedure > already defined. What I want is something like: > > generic > type X is private; > with procedure Y(Z : in X) is P; > package Foo > > > but of course P must already take into account X. With '95 I think I > could just with a generic package containing the stubs, but I can > figure out a way in '83. Yes, how can you have 'P' know which X? The best I can see is: package A is type A_T is private; procedure Y (Z : A_T); private type A_T is new Integer; end A; generic type X is private; with procedure Y (Z : X) is <>; package B is end B; with A; use A; with B; package C is new B (A_T); -- Picks up 'Y' by default Cheers -- Martin