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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!postnews.google.com!k37g2000hsf.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: numbers as 'generics' parameters Date: Sun, 18 May 2008 13:37:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0ebf73b9-4c38-4279-99de-da230e978c83@k37g2000hsf.googlegroups.com> References: <482dd91a$1_3@news.bluewin.ch> <1g4p2jgvi3k8j.1j2xk6p9ws3a2.dlg@40tude.net> <9e99c5cd-fd94-4a38-89fd-681c0372b7ad@y38g2000hsy.googlegroups.com> <1nng3xn67do3n$.1f4isrrr1y1m2.dlg@40tude.net> NNTP-Posting-Host: 85.3.116.127 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1211143071 32227 127.0.0.1 (18 May 2008 20:37:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 18 May 2008 20:37:51 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k37g2000hsf.googlegroups.com; posting-host=85.3.116.127; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:212 Date: 2008-05-18T13:37:47-07:00 List-Id: On 18 Maj, 16:52, "Dmitry A. Kazakov" wrote: > generic > N : Natural; > package Strings_Nobody_Ever_Needed is > type Pascal_String is new String (1..N); > procedure Foo (L, R : Pascal_String); > end Strings_Nobody_Ever_Needed; No. The package is already written and no code can be added. A child package would do, perhaps? Note also that the constraint to have equal strings is only an example and probably does not show the full problem. I might have written my code like this instead: template void foo(const fixed_size_string & s1, const fixed_size_string<2 * N> & s2); and it would ensure *at compile time* that the second string is twice as long as the first one. It should be obvious now that such a constraint can be anything that is computable (at compile time). What about this? (again: the package in question is read only) > If you replaced the type declaration in Strings_Nobody_Ever_Needed to > > subtype Pascal_String is String (1..N); > > you would start to see what's wrong with all this... (:-)) No, I don't follow. Could you please explain? > Talking about strings, they are allowed to have statically unknown length Yes - the string was only a vehicle to show the problem. It might be a matrix of size N or just about anything else. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com