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=0.5 required=5.0 tests=BAYES_05,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!o13g2000cwo.googlegroups.com!not-for-mail From: matteo.bordin@gmail.com Newsgroups: comp.lang.ada Subject: Re: prohibit certain generic instantiations in Ada 2005 Date: 12 Feb 2006 00:55:52 -0800 Organization: http://groups.google.com Message-ID: <1139734552.205623.152990@o13g2000cwo.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> NNTP-Posting-Host: 151.47.203.42 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1139734557 2194 127.0.0.1 (12 Feb 2006 08:55:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 12 Feb 2006 08:55:57 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: o13g2000cwo.googlegroups.com; posting-host=151.47.203.42; posting-account=F0PVCw0AAABbUMNt6pX6q_ZNh55rRxT7 Xref: g2news1.google.com comp.lang.ada:2864 Date: 2006-02-12T00:55:52-08:00 List-Id: As I explained in a prewieus post, my int/float example was just didactic. I want that kind of checking because I want to use generics as a generative environment for a component-based approach. If I can map to the source code the knowledge that some template instantiations are not allowed, then I can let the compiler check for me if the user of the library I am writing is doing something wrong. For example, imagine I want to compose a car component with an Engine and a Transmission. Electric engine can be coupled only with automatic transmission, while gasoline engine can work with both automatic and manual transmission. Then the Car component is: generic type My_Engine is new Engine with private; type My_Transmission is new Transmission with private; package Car is .... Then I want to prohibit: package My_Car is new Car(My_Engine => Electric_Engine, My_Transmission => Manual_Tansmission). As you can see there is a reason to do that. And there is other reasons to want static (compile-time) checking insteam of run-time exceptions.