comp.lang.ada
 help / color / mirror / Atom feed
* Why the scalar types are not all discrete types ?
@ 2000-10-13  0:00 Philippe Torres
  2000-10-13  0:00 ` Philippe Torres
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Torres @ 2000-10-13  0:00 UTC (permalink / raw)


I don't understand very well...

For instance, the fixed-point types have the attributes First, Last but
Pos is not permitted (only for discrete types if i got it right). Why ?
Because Pos is an integer and the range of the fixed-point type can be
bigger than the range of type Integer ?

I ask that because i would like to iterate over a fixed-point index in a
'for ... loop' but the 'for ... loop' demands a 'range' over a discrete
type.

Quite weird for me since 'range' can be used in a fixed-point type
declaration :
---
type fixed_2_digits is delta 0.1 range -20.0 .. 20.0 ;
---
As usual, i must miss something somewhere...

Philippe




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

* Re: Why the scalar types are not all discrete types ?
  2000-10-13  0:00 Why the scalar types are not all discrete types ? Philippe Torres
@ 2000-10-13  0:00 ` Philippe Torres
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Torres @ 2000-10-13  0:00 UTC (permalink / raw)


Philippe Torres wrote:
> 
> I ask that because i would like to iterate over a fixed-point index in a
> 'for ... loop' but the 'for ... loop' demands a 'range' over a discrete
> type.
> 

Don't bother, i've done it with
---
V : fixed_2_digits := start_of_range ;
end_of_loop_value : fixed_2_digits := end_of_range ;

loop 
  some_action_on(V) ;
  exit when V = end_of_loop_value ;
  V := V'Succ ;
end loop ;
---
Even if thinking about it once should have been enough, I'll think twice
next time. Promised.

Philippe




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

end of thread, other threads:[~2000-10-13  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-13  0:00 Why the scalar types are not all discrete types ? Philippe Torres
2000-10-13  0:00 ` Philippe Torres

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