comp.lang.ada
 help / color / mirror / Atom feed
* Re: array question
  1999-01-19  0:00 yukchi
@ 1999-01-18  0:00 ` bill
  1999-01-19  0:00   ` David C. Hoos, Sr.
  1999-01-19  0:00 ` Matthew Heaney
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: bill @ 1999-01-18  0:00 UTC (permalink / raw)


In article <78189o$2bj@eng-ser1.erg.cuhk.edu.hk>, ycli6@se.cuhk.edu.hk says...
 
>	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?
>

<> means the range is undertmined at type declaration time.
when you then define a variable this type, then you need to specify
the range. This way you can use the same type to define different
objects of that type of varying ranges. so you dont have to have
to declare a new type everytime where is the only difference
between them is the value of the range. this is called generic type.

yes, you can change INTEGER above. this is the type of the index. which
can be any scalar type.

check some of the Ada text books for examples.

bill
 




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

* array question
@ 1999-01-19  0:00 yukchi
  1999-01-18  0:00 ` bill
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: yukchi @ 1999-01-19  0:00 UTC (permalink / raw)


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!

--
****    ****  **    **  **      ** **     ** **   **     ** ** **
****   ****** ***  ***   **    **  **     ** **  **      ** ** **
 **    **  ** ********    **  **   **     ** ** **       ** ** **
 **    ****** ********     ****    **     ** ****        ** ** **
 **    ****** ** ** **      **     **     ** ** **       ** ** **
 **    **  ** **    **      **     **     ** **  **      
****   **  ** **    **      **     ********* **   **     ** ** **
****   **  ** **    **      **       *****   **    **    ** ** **




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

* Re: array question
  1999-01-19  0:00 yukchi
  1999-01-18  0:00 ` bill
@ 1999-01-19  0:00 ` Matthew Heaney
  1999-01-19  0:00 ` Tom Moran
  1999-01-23  0:00 ` Bryan Shayne
  3 siblings, 0 replies; 17+ messages in thread
From: Matthew Heaney @ 1999-01-19  0:00 UTC (permalink / raw)


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.




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

* Re: array question
  1999-01-18  0:00 ` bill
@ 1999-01-19  0:00   ` David C. Hoos, Sr.
  0 siblings, 0 replies; 17+ messages in thread
From: David C. Hoos, Sr. @ 1999-01-19  0:00 UTC (permalink / raw)



bill@nospam.com wrote in message <7819qk$cbj@drn.newsguy.com>...
>In article <78189o$2bj@eng-ser1.erg.cuhk.edu.hk>, ycli6@se.cuhk.edu.hk
says...
>
>> 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?
>>
>
><> means the range is undertmined at type declaration time.
>when you then define a variable this type, then you need to specify
>the range. This way you can use the same type to define different
>objects of that type of varying ranges. so you dont have to have
>to declare a new type everytime where is the only difference
>between them is the value of the range. this is called generic type.
>

This is not correct.  Such a type is called an _unconstrained_
array type.

>yes, you can change INTEGER above. this is the type of the index. which
>can be any scalar type.


This is wrong.  Array indices can be of any _discrete_ type.  This
means that the real scalar types are _excluded_

>
>check some of the Ada text books for examples.
>
>bill
>






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

* Re: array question
  1999-01-19  0:00 yukchi
  1999-01-18  0:00 ` bill
  1999-01-19  0:00 ` Matthew Heaney
@ 1999-01-19  0:00 ` Tom Moran
  1999-01-23  0:00 ` Bryan Shayne
  3 siblings, 0 replies; 17+ messages in thread
From: Tom Moran @ 1999-01-19  0:00 UTC (permalink / raw)


>	i want to ask a question in array.
>type MY_ARRAY is array(INTEGER range <>) of FLOAT;

>what is the meaning of <>, 
  It's indefinite - array of this type can have various lengths, eg
short : my_array(1 .. 10);
long : my_array(1 .. 10000);
   If you said instead
type my_other_array is array(integer range 1 .. 50) of float;
  then you could say
x : my_other_array;
y: my_other_array;
  but you couldn't say
z : my_other_array(1 .. 10);
  since my_other_array type was defined with fixed bounds of 1 .. 50

>also can i replace INTEGER with
>other type? such as FLOAT, BOOLEAN?
  Boolean yes, Float no.  (How would you go about setting the initial
values of an array(float range 0.1 .. 0.2)?  x(0.100000001) := 1;
x(0.100000002) := 2; etc?)  




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

* Re: array question
  1999-01-19  0:00 yukchi
                   ` (2 preceding siblings ...)
  1999-01-19  0:00 ` Tom Moran
@ 1999-01-23  0:00 ` Bryan Shayne
  3 siblings, 0 replies; 17+ messages in thread
From: Bryan Shayne @ 1999-01-23  0:00 UTC (permalink / raw)


<> means undefined.  You must define a constraint before actual usage
though.

yukchi wrote:

> 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!
>
> --
> ****    ****  **    **  **      ** **     ** **   **     ** ** **
> ****   ****** ***  ***   **    **  **     ** **  **      ** ** **
>  **    **  ** ********    **  **   **     ** ** **       ** ** **
>  **    ****** ********     ****    **     ** ****        ** ** **
>  **    ****** ** ** **      **     **     ** ** **       ** ** **
>  **    **  ** **    **      **     **     ** **  **
> ****   **  ** **    **      **     ********* **   **     ** ** **
> ****   **  ** **    **      **       *****   **    **    ** ** **





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

* array question
@ 2014-02-10  3:49 agent
  2014-02-10  5:39 ` Jeffrey Carter
  2014-02-10 13:40 ` Mike H
  0 siblings, 2 replies; 17+ messages in thread
From: agent @ 2014-02-10  3:49 UTC (permalink / raw)


I would like to define a array that can use a character as its index. 
type FSATyp is (Delim, Op, Dgt, AllElse);

FsaArray : ARRAY Character range ('' .. Character'Val(255)) OF FSATyp;

I'm getting an error saying that I'm missing '(' and extra ')' is
ignored.  It is also saying missing => and that strings are delimited
by double quotes.

I'm sure what I want is possible, but I seem to have the syntax wrong.

Any help would be appreciated.


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

* Re: array question
  2014-02-10  3:49 array question agent
@ 2014-02-10  5:39 ` Jeffrey Carter
  2014-02-10 12:41   ` agent
  2014-02-10 13:40 ` Mike H
  1 sibling, 1 reply; 17+ messages in thread
From: Jeffrey Carter @ 2014-02-10  5:39 UTC (permalink / raw)


On 02/09/2014 08:49 PM, agent@drrob1.com wrote:
> I would like to define a array that can use a character as its index.
> type FSATyp is (Delim, Op, Dgt, AllElse);
>
> FsaArray : ARRAY Character range ('' .. Character'Val(255)) OF FSATyp;

The syntax for an array definition is given in ARM 3.6 
(http://www.adaic.org/resources/add_content/standards/12rm/html/RM-3-6.html).

-- 
Jeff Carter
"I've got to stay here, but there's no reason
why you folks shouldn't go out into the lobby
until this thing blows over."
Horse Feathers
50

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

* Re: array question
  2014-02-10  5:39 ` Jeffrey Carter
@ 2014-02-10 12:41   ` agent
  0 siblings, 0 replies; 17+ messages in thread
From: agent @ 2014-02-10 12:41 UTC (permalink / raw)


On Sun, 09 Feb 2014 22:39:06 -0700, Jeffrey Carter
<spam.jrcarter.not@spam.not.acm.org> wrote:

>On 02/09/2014 08:49 PM, agent@drrob1.com wrote:
>> I would like to define a array that can use a character as its index.
>> type FSATyp is (Delim, Op, Dgt, AllElse);
>>
>> FsaArray : ARRAY Character range ('' .. Character'Val(255)) OF FSATyp;
>
>The syntax for an array definition is given in ARM 3.6 
>(http://www.adaic.org/resources/add_content/standards/12rm/html/RM-3-6.html).

Thanks


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

* Re: array question
  2014-02-10  3:49 array question agent
  2014-02-10  5:39 ` Jeffrey Carter
@ 2014-02-10 13:40 ` Mike H
  2014-02-10 15:13   ` Mike H
  1 sibling, 1 reply; 17+ messages in thread
From: Mike H @ 2014-02-10 13:40 UTC (permalink / raw)


In message <2migf9h07j7ll0eqk7oh3e64m1e0lv3r5r@4ax.com>, 
agent@drrob1.com writes
>I would like to define a array that can use a character as its index.
>type FSATyp is (Delim, Op, Dgt, AllElse);
>
>FsaArray : ARRAY Character range ('' .. Character'Val(255)) OF FSATyp;
>
type FsaArray_type is array (ASCII.nul .. ASCII.del) of FSATyp;
FsaArray : FsaArray_type := (others => ASCII.nul);
-- 
The thing I like best about the Internet is that no one
knows that, in reality, I am just another old dog!
Mike


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

* Re: array question
  2014-02-10 13:40 ` Mike H
@ 2014-02-10 15:13   ` Mike H
  2014-02-10 16:41     ` Robert A Duff
  2014-02-11  1:47     ` Dennis Lee Bieber
  0 siblings, 2 replies; 17+ messages in thread
From: Mike H @ 2014-02-10 15:13 UTC (permalink / raw)


In message <5aOMAcEhbN+SFw0R@ada-augusta.demon.co.uk>, Mike H 
<postmaster@ada-augusta.demon.co.uk> writes
>type FsaArray_type is array (ASCII.nul .. ASCII.del) of FSATyp;
>FsaArray : FsaArray_type := (others => ASCII.nul);
Whoops! An 80-year-old dog who is slipping into dementia?
-- 
The thing I like best about the Internet is that no one
knows that, in reality, I am just another old dog!
Mike


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

* Re: array question
  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-11  1:47     ` Dennis Lee Bieber
  1 sibling, 2 replies; 17+ messages in thread
From: Robert A Duff @ 2014-02-10 16:41 UTC (permalink / raw)


Mike H <postmaster@ada-augusta.demon.co.uk> writes:

> In message <5aOMAcEhbN+SFw0R@ada-augusta.demon.co.uk>, Mike H
> <postmaster@ada-augusta.demon.co.uk> writes
>>type FsaArray_type is array (ASCII.nul .. ASCII.del) of FSATyp;
>>FsaArray : FsaArray_type := (others => ASCII.nul);
> Whoops! An 80-year-old dog who is slipping into dementia?

;-)

How about:

type FsaArray_type is array (Character) of FSATyp;

?

- Bob

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

* Re: array question
  2014-02-10 16:41     ` Robert A Duff
@ 2014-02-10 17:02       ` Mike H
  2014-02-11 22:25       ` agent
  1 sibling, 0 replies; 17+ messages in thread
From: Mike H @ 2014-02-10 17:02 UTC (permalink / raw)


In message <wcck3d2ex7y.fsf@shell01.TheWorld.com>, Robert A Duff 
<bobduff@shell01.TheWorld.com> writes
>Mike H <postmaster@ada-augusta.demon.co.uk> writes:
>
>> In message <5aOMAcEhbN+SFw0R@ada-augusta.demon.co.uk>, Mike H
>> <postmaster@ada-augusta.demon.co.uk> writes
>>>type FsaArray_type is array (ASCII.nul .. ASCII.del) of FSATyp;
>>>FsaArray : FsaArray_type := (others => ASCII.nul);
>> Whoops! An 80-year-old dog who is slipping into dementia?
>
>;-)
>
>How about:
>
>type FsaArray_type is array (Character) of FSATyp;
Looks good to me! It is my second line that is rubbish. It should be ...
FsaArray : FsaArray_type;
My personal dislike of uninitialised variables tripped me up.

-- 
"Why," said Ford squatting down beside him and shivering, "are you lying face
down in the dust?" "It's a very effective way of being wretched," said Marvin.
Mike ;-(


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

* Re: array question
  2014-02-10 15:13   ` Mike H
  2014-02-10 16:41     ` Robert A Duff
@ 2014-02-11  1:47     ` Dennis Lee Bieber
  2014-02-11 14:22       ` Mike H
  1 sibling, 1 reply; 17+ messages in thread
From: Dennis Lee Bieber @ 2014-02-11  1:47 UTC (permalink / raw)


On Mon, 10 Feb 2014 15:13:57 +0000, Mike H
<postmaster@ada-augusta.demon.co.uk> declaimed the following:

>In message <5aOMAcEhbN+SFw0R@ada-augusta.demon.co.uk>, Mike H 
><postmaster@ada-augusta.demon.co.uk> writes
>>type FsaArray_type is array (ASCII.nul .. ASCII.del) of FSATyp;
>>FsaArray : FsaArray_type := (others => ASCII.nul);
>Whoops! An 80-year-old dog who is slipping into dementia?

	Say it isn't so... You're scaring this 55 year old Vargr

-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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

* Re: array question
  2014-02-11  1:47     ` Dennis Lee Bieber
@ 2014-02-11 14:22       ` Mike H
  0 siblings, 0 replies; 17+ messages in thread
From: Mike H @ 2014-02-11 14:22 UTC (permalink / raw)


Dennis Lee Bieber writes...
>       Say it isn't so... You're scaring this 55 year old Vargr
Oh Dear! You have another 25 years to go before your age becomes 
something to boast about!

-- 
"Life is not a journey to the grave with the intention of arriving safely
in a well preserved body, but rather to skid in broadside, thoroughly used up,
totally worn out and loudly proclaiming; WOW!!! What a ride."
Mike ;-)

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

* Re: array question
  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
  1 sibling, 1 reply; 17+ messages in thread
From: agent @ 2014-02-11 22:25 UTC (permalink / raw)


On Mon, 10 Feb 2014 11:41:53 -0500, Robert A Duff
<bobduff@shell01.TheWorld.com> wrote:

>Mike H <postmaster@ada-augusta.demon.co.uk> writes:
>
>> In message <5aOMAcEhbN+SFw0R@ada-augusta.demon.co.uk>, Mike H
>> <postmaster@ada-augusta.demon.co.uk> writes
>>>type FsaArray_type is array (ASCII.nul .. ASCII.del) of FSATyp;
>>>FsaArray : FsaArray_type := (others => ASCII.nul);
>> Whoops! An 80-year-old dog who is slipping into dementia?
>
>;-)
>
>How about:
>
>type FsaArray_type is array (Character) of FSATyp;
>
>?
>
>- Bob

How simple and elegent.  And it worked for me.

Thanks.


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

* Re: array question
  2014-02-11 22:25       ` agent
@ 2014-02-12 16:48         ` Mike H
  0 siblings, 0 replies; 17+ messages in thread
From: Mike H @ 2014-02-12 16:48 UTC (permalink / raw)


In message <qp8lf9p2a6gpnrhkcd5b342mgpg6ftgob7@4ax.com>, 
agent@drrob1.com writes
>
>How simple and elegent.  And it worked for me.
>
Welcome to the friendly fields of Ada-land!
-- 
"Whom the gods would destroy, they first invite to program in C"
Mike

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

end of thread, other threads:[~2014-02-12 16:48 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-10  3:49 array question 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
  -- strict thread matches above, loose matches on Subject: below --
1999-01-19  0:00 yukchi
1999-01-18  0:00 ` bill
1999-01-19  0:00   ` David C. Hoos, Sr.
1999-01-19  0:00 ` Matthew Heaney
1999-01-19  0:00 ` Tom Moran
1999-01-23  0:00 ` Bryan Shayne

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