comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian_drummond@btconnect.com>
Subject: Re: Ada Smileys in C++ lib Conversion
Date: Mon, 16 Aug 2010 22:39:22 +0100
Date: 2010-08-16T22:39:22+01:00	[thread overview]
Message-ID: <kt9j66l9a9har44trma2iu3j1ff16lalfi@4ax.com> (raw)
In-Reply-To: 4915efdd-46ba-436b-b989-6067ce5a03bf@i31g2000yqm.googlegroups.com

On Mon, 16 Aug 2010 05:39:34 -0700 (PDT), Maciej Sobczak
<see.my.homepage@gmail.com> wrote:

>On 16 Sie, 14:30, Brian Drummond <brian_drumm...@btconnect.com> wrote:

>> So a "const" is not constant, says the compiler.
>
>The above is guaranteed to work by the C++ standard (nerds see
>5.19/1).

And it does work in C++. 
(It was clear I was talking about C, yes?).

>The problem will be when the initializer for "size" above will indeed
>be a function call - this would not be a constant expression, even
>though the object "size" is declared as const.
>The reason is that constant expression should always evaluate to the
>same value, whereas function calls are not required (and cannot be
>verified) to do so. 
... even though the function is only called once to initialise the const - and
it is a "pure function" in Ada or VHDL terms - and all its arguments are consts
(or even constants!). Does make me wonder what _can_ be verified in C++.

>So, there is a difference between a "constant expression" (roughly
>equivalent to Ada's "static expression") and a "const object".
>Array bounds require constant expression.

So we have - even in C++ - a const object that cannot be used 
where a constant expression is required.

Interesting, Thanks.

To get back almost on-topic, I am frequently amazed in Ada, after years of
bruising by various {}-languages, how often I can program from the BNF, (i.e.
"the BNF doesn't stop me doing this, but surely it can't be THAT simple..." 
and it just works. 

- Brian ... smiling



  reply	other threads:[~2010-08-16 21:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-13 14:20 Ada Smileys in C++ lib Conversion Warren
2010-08-13 15:06 ` Yannick Duchêne (Hibou57)
2010-08-13 16:53 ` Anh Vo
2010-08-14  1:36   ` Warren
2010-08-14  9:52     ` Georg Bauhaus
2010-08-14 10:57     ` Brian Drummond
2010-08-14 20:34       ` Maciej Sobczak
2010-08-14 21:01         ` Dmitry A. Kazakov
2010-08-15  1:16         ` Brian Drummond
2010-08-15 10:04           ` Maciej Sobczak
2010-08-16 12:08             ` Brian Drummond
2010-08-16 12:13               ` Georg Bauhaus
2010-08-16 12:30             ` Brian Drummond
2010-08-16 12:39               ` Maciej Sobczak
2010-08-16 21:39                 ` Brian Drummond [this message]
2010-08-16 22:53                   ` Robert A Duff
2010-08-24 10:12           ` David Thompson
2010-08-30  9:51             ` Brian Drummond
2010-08-16 14:54       ` Warren
2010-08-16 20:27         ` Maciej Sobczak
2010-08-17 12:57           ` Warren
2010-08-17 13:37             ` Maciej Sobczak
2010-08-17 15:07               ` Georg Bauhaus
2010-08-18 17:31               ` Warren
2010-08-24 10:12             ` David Thompson
replies disabled

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