comp.lang.ada
 help / color / mirror / Atom feed
From: "Martin Dowie" <martin.dowie@no.sp.am.btopenworld.com>
Subject: Re: Can help me interpret this in Ada! Newbie here
Date: Fri, 1 Nov 2002 16:53:54 +0000 (UTC)
Date: 2002-11-01T16:53:54+00:00	[thread overview]
Message-ID: <apubj2$h9n$1@sparta.btinternet.com> (raw)
In-Reply-To: 3dc2adbc$1@news.starhub.net.sg

"ulysses" <ulysses_w@hotmail.com> wrote in message
news:3dc2adbc$1@news.starhub.net.sg...
> subtype SRU_ID_Type is Machine.Bit_4 range 0 .. 6 ;  <--- what does it
mean
> it Ada
>
> Ok does this means it's an array of 7 Machine.Bit_4 ??

No, it means it is declaring a type with a range based on the type
"Bit_4", which is declared in package Machine. Presumably the
type "Bit_4" is a type that defined as having a "'Size" of 4 (4 bits).

The 'sub' in 'subtype' is important though - it means it isn't creating
a whole new type but rather using all the information from an existing
type (in this case 'Bit_4') but adding a further restriction. All the
routines that are available to 'Bit_4' can be made available to the
new subtype without the need for an explicit type conversion.

So, you couldn't declare local procedures:
   procedure Do_Something (X : Machine.Bit_4);

and
   procedure Do_Something (X : SRU_ID_Type);

as "SRU_ID_Type" is really a special case of "Machine.Bit_4" already.

Go to http://www.it.bton.ac.uk/staff/je/adacraft/ and read section 5.3,
preferably having read all the previous chapters first! :-)


Also, see www.adapower.com






      parent reply	other threads:[~2002-11-01 16:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-01 16:37 Can help me interpret this in Ada! Newbie here ulysses
2002-11-01 16:48 ` Preben Randhol
2002-11-01 16:53 ` Martin Dowie [this message]
replies disabled

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