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!y38g2000hsy.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: numbers as 'generics' parameters Date: Sun, 18 May 2008 06:58:03 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <482dd91a$1_3@news.bluewin.ch> <1g4p2jgvi3k8j.1j2xk6p9ws3a2.dlg@40tude.net> <9e99c5cd-fd94-4a38-89fd-681c0372b7ad@y38g2000hsy.googlegroups.com> NNTP-Posting-Host: 85.3.99.233 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1211119084 27920 127.0.0.1 (18 May 2008 13:58:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 18 May 2008 13:58:04 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y38g2000hsy.googlegroups.com; posting-host=85.3.99.233; 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:201 Date: 2008-05-18T06:58:03-07:00 List-Id: On 17 Maj, 19:34, "Dmitry A. Kazakov" wrote: > How are going to check string length statically? That's what I'm asking. OP asked about numbers in generics, motivating his question with compile-time checks. Surely he comes from C++ and he was later flooded with answers that focused on numbers, generics and alternatives, but the "compile-time" part of the discussion was immediately lost. I can bet that OP was asking about this: template void foo(const fixed_size_string & s1, const fixed_size_string & s2) { // some processing here } fixed_size_string<3> s = "Ada"; fixed_size_string<3> t = "C++"; fixed_size_string<4> u = "Java" foo(s, t); // OK, s and t have statically equal lengths foo(s, u); // compile-time error *here* Yes, Ada allows to use numbers in types - in various ways. But the OP's question is still not directly addressed. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com