comp.lang.ada
 help / color / mirror / Atom feed
* Can help me interpret this in Ada! Newbie here
@ 2002-11-01 16:37 ulysses
  2002-11-01 16:48 ` Preben Randhol
  2002-11-01 16:53 ` Martin Dowie
  0 siblings, 2 replies; 3+ messages in thread
From: ulysses @ 2002-11-01 16:37 UTC (permalink / raw)


Hi there,

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 ??

  Translate_SRU_ID_To_Fail_ID
      : constant array(SRU_ID_Type) of BIT_Fail_ID_Type
      := (
           0 => Antenna,
           1 => Processor,
           2 => Synthesizer,
           3 => GUARD_Rx,
           4 => Main_Rx,
           5 => Power_Supply,
           6 => Main_Tx
          ) ;

Next qn, so how each of these represent in bit format ??

Thanks for any help ....





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

* Re: Can help me interpret this in Ada! Newbie here
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Preben Randhol @ 2002-11-01 16:48 UTC (permalink / raw)


ulysses wrote:
> Hi there,
> 
> subtype SRU_ID_Type is Machine.Bit_4 range 0 .. 6 ;  <--- what does it mean
> it Ada

Read : http://www.it.bton.ac.uk/staff/je/adacraft/ch05.htm#5.3

> 
> Ok does this means it's an array of 7 Machine.Bit_4 ??
> 
>   Translate_SRU_ID_To_Fail_ID
>       : constant array(SRU_ID_Type) of BIT_Fail_ID_Type
>       := (
>            0 => Antenna,
>            1 => Processor,
>            2 => Synthesizer,
>            3 => GUARD_Rx,
>            4 => Main_Rx,
>            5 => Power_Supply,
>            6 => Main_Tx
>           ) ;
> 

Read : http://www.it.bton.ac.uk/staff/je/adacraft/ch06.htm#6.3

-- 
Preben Randhol  --------------------  http://www.pvv.org/~randhol
�.., chaos is found in greatest abundance wherever order is being
sought. It always defeats order, because it is better organized.�
                            -- Interesting Times, Terry Pratchett



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

* Re: Can help me interpret this in Ada! Newbie here
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Dowie @ 2002-11-01 16:53 UTC (permalink / raw)


"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






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

end of thread, other threads:[~2002-11-01 16:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox