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,f30ef262af690ce0 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!198.186.194.250.MISMATCH!news-xxxfer.readnews.com!textspool1.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Fri, 16 May 2008 19:09:52 -0400 From: "Peter C. Chapin" User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: numbers as 'generics' parameters References: <482dd91a$1_3@news.bluewin.ch> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <482e143e$0$11203$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: 44a79da4.news.sover.net X-Trace: DXC=jgY Maciej Sobczak wrote: > On 16 Maj, 20:57, Gautier wrote: > >> generic >> N: Integer; >> package Fixed_size_vectors is >> Vector: array(1..N) of Float; > > I guess: > type Vector is array (1..N) of Float; > >> end; > > How to write an operation that ensures *at compile time* that its two > parameters are Fixed_size_vectors of equal N? I may not understand the question, but isn't this trivial? procedure Check is package Short_Vectors is new Fixed_Size_Vectors(N => 3); package Long_Vectors is new Fixed_Size_Vectors(N => 6); V1 : Short_Vectors.Vector; V2, V3 : Long_Vectors.Vector; begin V3 := V1 + V2; end Check; Assuming an appropriate overload for "+" this produces a compile time error for me. Peter