From: mheaney@ni.net (Matthew Heaney)
Subject: Re: for-loop parameters
Date: 1997/09/25
Date: 1997-09-25T00:00:00+00:00 [thread overview]
Message-ID: <mheaney-ya023680002509971927280001@news.ni.net> (raw)
In-Reply-To: EH0yCt.43p.0.-s@inmet.camb.inmet.com
In article <EH0yCt.43p.0.-s@inmet.camb.inmet.com>,
stt@houdini.camb.inmet.com (Tucker Taft) wrote:
>The syntax for a "for" loop includes the ability to specify explicitly
>the type of the loop parameter. By default, it is determined by the
>type of the low and high bound, and if both are "universal" integers,
>then it uses Standard.Integer as a fallback.
>
>For example:
>
> for I in 1..10 loop -- uses Standard.Integer
>
> for MI in My_Integer range 1..10 loop -- uses My_Integer
I like the latter formulation - always try to assert the type of the index
explicitly. For example, a better way to formulate the former would be
for I in Integer range 1 .. 10 loop
If I is used to index an array, then asserting the array index subtype
directly is better still (this can also turn some constraint checks off).
Matt
--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271
next prev parent reply other threads:[~1997-09-25 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-24 0:00 for-loop parameters CMSC 330-4021 Student 23
1997-09-24 0:00 ` Tucker Taft
1997-09-25 0:00 ` Matthew Heaney [this message]
1997-09-25 0:00 ` Charles Rose
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox