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,262b74f44c7f873e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: prohibit certain generic instantiations in Ada 2005 Date: 13 Feb 2006 11:14:50 -0800 Organization: http://groups.google.com Message-ID: <1139858090.274110.26950@g44g2000cwa.googlegroups.com> References: <1139508110.410006.28260@g14g2000cwa.googlegroups.com> <1139515341.782860.197930@f14g2000cwb.googlegroups.com> <1139581110.636535.107910@g44g2000cwa.googlegroups.com> <1139645084.563448.239040@g47g2000cwa.googlegroups.com> <1139734552.205623.152990@o13g2000cwo.googlegroups.com> NNTP-Posting-Host: 66.162.65.162 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1139858095 5260 127.0.0.1 (13 Feb 2006 19:14:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 13 Feb 2006 19:14:55 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g44g2000cwa.googlegroups.com; posting-host=66.162.65.162; posting-account=Zl1UPAwAAADEsUSm1PMMiDjihtBlZUi_ Xref: g2news1.google.com comp.lang.ada:2880 Date: 2006-02-13T11:14:50-08:00 List-Id: Ada does have something called "signature packages" that are probably what you're looking for. The problem with your previous solutions is that you're trying to use types to solve your problem, instead of using generics to solve your problem (which was your original request). You want to be doing something like: generic type Engine is limited private; type Transmission is limited private; with procedure Attach (E : in out Engine; T : in out Transmission) is <>; with package Generic_Cars is ... end; Don't import generic formal tagged types if you don't need them. You only end up overcommitting yourself. Note that a limited private generic formal is a superset of tagged (limited), so you're still free to instantiate Generic_Cars with a tagged generic actual. You want to prevent attaching an electric engine to a manual transmission. That's fine. If no Attach for binding an electric engine to a manual transmission exists, then your problem is solved since you have no generic actual with which to instantiate the package. Stop trying to import tagged types. The only reason you'd need to do that is if the generic package itself needs to extend the formal type. Now that that's out of the way, I can get to what I mentioned at the top of my post. It's possible that the set of operations for engines and transmissions needed by the generic is large, and so the generic formal region becomes long since you must declare all the formal operations. To simplify things you can declare all the engine operations in a separate package (and do the same for the transmission in another package, if necessary), and then import an instantiation of the engine "signature" package as a generic formal, like this: generic type Engine (<>) is limited private; with procedure XXX (E : in out Engine) is <>; package Generic_Engines is end; -- yes, spec is empty Now you can do this: generic type Engine is limited private; type Transmission is limited private; with Engines is new Generic_Engines (Engine, others => <>); -- verify my syntax with procedure Attach (E : in out Engine; ...) is <>; package Generic_Cars is ... end; That way you can instantiate the Generic_Engines package once for each interesting engine type (note again that you do NOT need a tagged type here), and then use that signature package as the generic actual. Stop using tagged types for everything. You want signature packages.