comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: array question
Date: 1999/01/19
Date: 1999-01-19T00:00:00+00:00	[thread overview]
Message-ID: <m3g197afl8.fsf@mheaney.ni.net> (raw)
In-Reply-To: 78189o$2bj@eng-ser1.erg.cuhk.edu.hk

ycli6@se.cuhk.edu.hk (yukchi) writes:

> hihi,
> 	i want to ask a question in array.
> type MY_ARRAY is array(INTEGER range <>) of FLOAT;
> 
> what is the meaning of <>, also can i replace INTEGER with
> other type? such as FLOAT, BOOLEAN?
> 
> Thanks!
> 
> --
> ****    ****  **    **  **      ** **     ** **   **     ** ** **
> ****   ****** ***  ***   **    **  **     ** **  **      ** ** **
>  **    **  ** ********    **  **   **     ** ** **       ** ** **
>  **    ****** ********     ****    **     ** ****        ** ** **
>  **    ****** ** ** **      **     **     ** ** **       ** ** **
>  **    **  ** **    **      **     **     ** **  **      
> ****   **  ** **    **      **     ********* **   **     ** ** **
> ****   **  ** **    **      **       *****   **    **    ** ** **

Yes, you are Yuk.  Please get rid of this signature.  It is very
annoying.

The "<>" is refered to as "box."  It means that information has been
omitted.  Here, in your array declaration, it means that you are omitted
index constraints in the type.

Objects of that type can have any index constraints:

procedure Op (X : in My_Array) is
begin
   ... X'First can be any value in type Integer
   ... X'Last can be any value in type Integer

However, compare that with

subtype Matts_Array is My_Array (1 .. 10);

Now we have declared a subtype that constrains the index of the base
type My_Array.  We could do something similar using a completely
different type:

type Matts_Array is array (Integer range 1 .. 10) of Float;

Objects of (sub)type Matts_Array all have index values such that X'First
is 1, and X'Last is 10.

An array can be indexed by any discrete type (integer types or
enumeration types).  That means Float is not acceptable, becuase that
type is a floating point type, not a discrete type.  However, Boolean is
acceptable, becuase it is a discrete type.

Please get rid of your annoying signiture.




  parent reply	other threads:[~1999-01-19  0:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-19  0:00 array question yukchi
1999-01-18  0:00 ` bill
1999-01-19  0:00   ` David C. Hoos, Sr.
1999-01-19  0:00 ` Tom Moran
1999-01-19  0:00 ` Matthew Heaney [this message]
1999-01-23  0:00 ` Bryan Shayne
  -- strict thread matches above, loose matches on Subject: below --
2014-02-10  3:49 agent
2014-02-10  5:39 ` Jeffrey Carter
2014-02-10 12:41   ` agent
2014-02-10 13:40 ` Mike H
2014-02-10 15:13   ` Mike H
2014-02-10 16:41     ` Robert A Duff
2014-02-10 17:02       ` Mike H
2014-02-11 22:25       ` agent
2014-02-12 16:48         ` Mike H
2014-02-11  1:47     ` Dennis Lee Bieber
2014-02-11 14:22       ` Mike H
replies disabled

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