comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: numbers as 'generics' parameters
Date: Sun, 18 May 2008 06:58:03 -0700 (PDT)
Date: 2008-05-18T06:58:03-07:00	[thread overview]
Message-ID: <dda74cc4-302b-43fd-9aa0-16fda165a48f@y38g2000hsy.googlegroups.com> (raw)
In-Reply-To: lb3x7vq9qqne$.166q2d55sqtae$.dlg@40tude.net

On 17 Maj, 19:34, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
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 <size_t N>
void foo(const fixed_size_string<N> & s1,
         const fixed_size_string<N> & 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



  reply	other threads:[~2008-05-18 13:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-16 17:26 numbers as 'generics' parameters jhc0033
2008-05-16 17:55 ` Adam Beneschan
2008-05-16 19:12   ` John B. Matthews
2008-05-16 18:34 ` jimmaureenrogers
2008-05-16 18:57 ` Gautier
2008-05-16 20:52   ` Maciej Sobczak
2008-05-16 23:09     ` Peter C. Chapin
2008-05-17  7:47     ` Dmitry A. Kazakov
2008-05-17 16:29       ` Maciej Sobczak
2008-05-17 17:34         ` Dmitry A. Kazakov
2008-05-18 13:58           ` Maciej Sobczak [this message]
2008-05-18 14:52             ` Dmitry A. Kazakov
2008-05-18 20:37               ` Maciej Sobczak
2008-05-19  9:02                 ` Dmitry A. Kazakov
2008-05-19  5:16             ` Ivan Levashew
2008-05-19  8:26               ` Maciej Sobczak
2008-05-16 20:22 ` Jeffrey R. Carter
2008-05-21 15:32   ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox