comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado Alves <amado.alves@netcabo.pt>
Cc: comp.lang.ada@ada-france.org
Subject: Re: Why can't you create a out of order subtype?
Date: Thu, 3 Feb 2005 20:22:02 +0000
Date: 2005-02-03T20:22:02+00:00	[thread overview]
Message-ID: <mailman.121.1107462019.527.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <wccpszhctzo.fsf@shell01.TheWorld.com>

On 3 Feb 2005, at 19:40, Robert A Duff wrote:

> Martin Dowie <martin.dowie@btopenworld.com> writes:
>
>> Marius Amado Alves wrote:
>>> For run-time I find the "Value of Image" idiom a better one. It's
>>> readily available. No Unchecked_Conversion required.
>>> declare
>>>    M : Msg := Whatever;
>>>    V : Vowelmsg;
>>> begin
>>>    V := Vowelmsg'Value (Msg'Image (M));
>>>    -- if control reaches here then M is a vowel
>>> exception
>>>    when Constraint_Error => -- M is not a vowel
>>> end;
>
> If there are no further uses of V, then I think 11.6 allows the 
> compiler
> to eliminate the raising of Constraint_Error.  I don't much like
> 11.6...
>
>> That's very, very, very slow...
>
> True (if it works at all).

Before I though you were complaining about the slowness of the Image 
(Value) operations (because there is probably parsing involved and 
string values on and off the stack) compared with unchecked conversion 
and 'Valid (which is very probably faster). Now I realise that you were 
probably complaining about the slowness of the exception handling 
mechanism. In that case, my experience with GNAT is that it is not that 
slow at all. I've made controlled experiments in the past. I think I 
reported them here.

Now, you made me take a look at 11.6 and yes, it seems if V is not used 
it can simply hold an undefined result and the exception not raised. 
But I bet you'll get a compiler warning. And rightly so, as unused 
variables are almost certainly a logic bug. It would in this case. 
Unless Vowelmsg were controlled and the logic put on Adjust or 
something. But then the compiler would consider V used, no?




  reply	other threads:[~2005-02-03 20:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-01 23:51 Why can't you create a out of order subtype? brett_gengler
2005-02-02  0:24 ` Jeffrey Carter
2005-02-02 17:55   ` Marius Amado Alves
2005-02-02 18:50     ` Pascal Obry
2005-02-02 20:22       ` Marius Amado Alves
2005-02-03  4:36       ` Wes Groleau
2005-02-03 12:59         ` Marius Amado Alves
2005-02-04  3:42           ` Wes Groleau
2005-02-02 19:35     ` Martin Dowie
2005-02-02 20:35       ` Marius Amado Alves
2005-02-02 21:18         ` Martin Dowie
2005-02-03 19:40       ` Robert A Duff
2005-02-03 20:22         ` Marius Amado Alves [this message]
2005-02-03 22:05           ` Robert A Duff
2005-02-04  6:49           ` Martin Dowie
2005-02-02 22:26 ` Georg Bauhaus
2005-02-03 23:09 ` 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