comp.lang.ada
 help / color / mirror / Atom feed
* null array constant in Ada 83
@ 2009-06-23  8:57 Martin Krischik
  2009-06-23  9:26 ` Peter Hermann
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Martin Krischik @ 2009-06-23  8:57 UTC (permalink / raw)


Hi,

maintaining old code is such a great fun. Anybody know what goes where
the 4 dots are (an appropriate N_Sel_List_Entry is declared).

   subtype T_Sel_Entries is Integer range 0 ..
Selection_Types.Max_Selection_Results;

   type T_Sel_List is array (T_Sel_Entries range <>) of T_Sel_List_Entry;

   N_Sel_List : constant T_Sel_List (1 .. 0) := ....;

Or is it just plain impossible in Ada 83.

Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: null array constant in Ada 83
  2009-06-23  8:57 null array constant in Ada 83 Martin Krischik
@ 2009-06-23  9:26 ` Peter Hermann
  2009-06-23  9:30 ` Frank J. Lhota
  2009-06-23  9:31 ` AdaMagica
  2 siblings, 0 replies; 7+ messages in thread
From: Peter Hermann @ 2009-06-23  9:26 UTC (permalink / raw)


(others => ...



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: null array constant in Ada 83
  2009-06-23  8:57 null array constant in Ada 83 Martin Krischik
  2009-06-23  9:26 ` Peter Hermann
@ 2009-06-23  9:30 ` Frank J. Lhota
  2009-06-23 12:04   ` Martin Krischik
  2009-06-23  9:31 ` AdaMagica
  2 siblings, 1 reply; 7+ messages in thread
From: Frank J. Lhota @ 2009-06-23  9:30 UTC (permalink / raw)


Martin Krischik wrote:
> Hi,
> 
> maintaining old code is such a great fun. Anybody know what goes where
> the 4 dots are (an appropriate N_Sel_List_Entry is declared).
> 
>    subtype T_Sel_Entries is Integer range 0 ..
> Selection_Types.Max_Selection_Results;
> 
>    type T_Sel_List is array (T_Sel_Entries range <>) of T_Sel_List_Entry;
> 
>    N_Sel_List : constant T_Sel_List (1 .. 0) := ....;
> 
> Or is it just plain impossible in Ada 83.
> 
> Regards
> 
> Martin

If N_Sel_Entry_Value is a value of type N_Sel_List_Entry, then you could 
write

    N_Sel_List : constant T_Sel_List (1 .. 0) :=
       (1 .. 0 => N_Sel_Entry_Value);

The fact that you have to provide a component value that is never used 
is a well known annoyance.
-- 
"All things extant in this world,
Gods of Heaven, gods of Earth,
Let everything be as it should be;
Thus shall it be!"
- Magical chant from "Magical Shopping Arcade Abenobashi"

"Drizzle, Drazzle, Drozzle, Drome,
Time for this one to come home!"
- Mr. Wizard from "Tooter Turtle"



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: null array constant in Ada 83
  2009-06-23  8:57 null array constant in Ada 83 Martin Krischik
  2009-06-23  9:26 ` Peter Hermann
  2009-06-23  9:30 ` Frank J. Lhota
@ 2009-06-23  9:31 ` AdaMagica
  2 siblings, 0 replies; 7+ messages in thread
From: AdaMagica @ 2009-06-23  9:31 UTC (permalink / raw)


  N_Sel_List: constant T_Sel_List (1 .. 0) := (others => some_value);

should be OK (some_value will not be evaluated since the range is
empty).



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: null array constant in Ada 83
  2009-06-23  9:30 ` Frank J. Lhota
@ 2009-06-23 12:04   ` Martin Krischik
  2009-06-23 13:05     ` Jean-Pierre Rosen
  2009-06-23 14:11     ` anon
  0 siblings, 2 replies; 7+ messages in thread
From: Martin Krischik @ 2009-06-23 12:04 UTC (permalink / raw)


Frank J. Lhota schrieb:
> Martin Krischik wrote:
>> Hi,
>>
>> maintaining old code is such a great fun. Anybody know what goes where
>> the 4 dots are (an appropriate N_Sel_List_Entry is declared).
>>
>>    subtype T_Sel_Entries is Integer range 0 ..
>> Selection_Types.Max_Selection_Results;
>>
>>    type T_Sel_List is array (T_Sel_Entries range <>) of T_Sel_List_Entry;
>>
>>    N_Sel_List : constant T_Sel_List (1 .. 0) := ....;
>>
>> Or is it just plain impossible in Ada 83.
>>
>> Regards
>>
>> Martin
> 
> If N_Sel_Entry_Value is a value of type N_Sel_List_Entry, then you could
> write
> 
>    N_Sel_List : constant T_Sel_List (1 .. 0) :=
>       (1 .. 0 => N_Sel_Entry_Value);

I see - I tried "other =>" - and that did not work at least not with Ada 83.

> The fact that you have to provide a component value that is never used
> is a well known annoyance.

I know. Even more interesting is creating a constant of a null record
(tied that in a prototype just recently). I found the syntax in the Ada
95 RM only to find out that Ada 83 does not know about it. But since it
was a prototype I did not bother looking into it.

Martin

-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: null array constant in Ada 83
  2009-06-23 12:04   ` Martin Krischik
@ 2009-06-23 13:05     ` Jean-Pierre Rosen
  2009-06-23 14:11     ` anon
  1 sibling, 0 replies; 7+ messages in thread
From: Jean-Pierre Rosen @ 2009-06-23 13:05 UTC (permalink / raw)


Martin Krischik a écrit :
>>    N_Sel_List : constant T_Sel_List (1 .. 0) :=
>>       (1 .. 0 => N_Sel_Entry_Value);
> 
> I see - I tried "other =>" - and that did not work at least not with Ada 83.
> 
True. The contexts where others => is allowed were extended in Ada 95,
and this is one of them.

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: null array constant in Ada 83
  2009-06-23 12:04   ` Martin Krischik
  2009-06-23 13:05     ` Jean-Pierre Rosen
@ 2009-06-23 14:11     ` anon
  1 sibling, 0 replies; 7+ messages in thread
From: anon @ 2009-06-23 14:11 UTC (permalink / raw)


Even though there are many features that are the same, there are 
also many changes from Ada 83 to Ada 95 or Ada 2005 so that you 
should download and use the Ada 83 LRM for maintain Ada 83 programs.


So you might need to use "'First" or "'Last" to define a initial value 

   -- N_Sel_Entry_Value is used set to an inital value 

   N_Sel_Entry_Value : constant T_Sel_List_Entry := T_Sel_List_Entry'First;  

   N_Sel_List : constant T_Sel_List (1 .. 0) := (1 .. 0 => N_Sel_Entry_Value);



Ada 83 RM 3.2.1

    OPTION      : BIT_VECTOR(1 .. 10) := (others => TRUE); 

Then Ada 83 RM 3.6 defines
    type TABLE    is array(1 .. 10) of INTEGER;

then from, Ada 83 RM 4.3.2  Array Aggregates

    TABLE'(5, 8, 4, 1, others => 0)  --  see 3.6 





In <4a40c4e8$1@news.post.ch>, Martin Krischik <krischik@users.sourceforge.net> writes:
>Frank J. Lhota schrieb:
>> Martin Krischik wrote:
>>> Hi,
>>>
>>> maintaining old code is such a great fun. Anybody know what goes where
>>> the 4 dots are (an appropriate N_Sel_List_Entry is declared).
>>>
>>>    subtype T_Sel_Entries is Integer range 0 ..
>>> Selection_Types.Max_Selection_Results;
>>>
>>>    type T_Sel_List is array (T_Sel_Entries range <>) of T_Sel_List_Entry;
>>>
>>>    N_Sel_List : constant T_Sel_List (1 .. 0) := ....;
>>>
>>> Or is it just plain impossible in Ada 83.
>>>
>>> Regards
>>>
>>> Martin
>> 
>> If N_Sel_Entry_Value is a value of type N_Sel_List_Entry, then you could
>> write
>> 
>>    N_Sel_List : constant T_Sel_List (1 .. 0) :=
>>       (1 .. 0 => N_Sel_Entry_Value);
>
>I see - I tried "other =>" - and that did not work at least not with Ada 83.
>
>> The fact that you have to provide a component value that is never used
>> is a well known annoyance.
>
>I know. Even more interesting is creating a constant of a null record
>(tied that in a prototype just recently). I found the syntax in the Ada
>95 RM only to find out that Ada 83 does not know about it. But since it
>was a prototype I did not bother looking into it.
>
>Martin
>
>-- 
>mailto://krischik@users.sourceforge.net
>Ada programming at: http://ada.krischik.com




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-06-23 14:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-23  8:57 null array constant in Ada 83 Martin Krischik
2009-06-23  9:26 ` Peter Hermann
2009-06-23  9:30 ` Frank J. Lhota
2009-06-23 12:04   ` Martin Krischik
2009-06-23 13:05     ` Jean-Pierre Rosen
2009-06-23 14:11     ` anon
2009-06-23  9:31 ` AdaMagica

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