From: Jeffrey Carter <spam@spam.com>
Subject: Re: HELP ! Problems with Get and Put in Generic Procedure
Date: Fri, 11 Jul 2003 01:59:42 GMT
Date: 2003-07-11T01:59:42+00:00 [thread overview]
Message-ID: <3F0E1A33.5090100@spam.com> (raw)
In-Reply-To: 9f383bcd.0307101401.60625c77@posting.google.com
Tanya wrote:
R. Eachus addressed your question, but there's another likely
misunderstanding on your part I'd like to mention.
>
> (generic spec file) ******************************************
>
> GENERIC
>
> TYPE ElementType IS PRIVATE; -- any nonlimited type
> TYPE IndexType IS ( <> ); -- any discrete type for
> -- index value
> TYPE ArrayType IS ARRAY (IndexType RANGE <>) OF ElementType;
>
> WITH PROCEDURE Read (Item : IN ElementType);
Mode "in" seems odd for a procedure named Read.
>
> PROCEDURE Get_Array_Generic (List : IN OUT ArrayType);
> -- Input : Array type and input file stream.
> -- Action: Will read in elements and store in array.
> -- Output: Array filled with elements.
>
>
> (generic body file) ********************************************
>
> PROCEDURE Get_Array_Generic (List : IN OUT ArrayType) IS
> -------------------------------------------------------------------
> -- Input : Array type and input file stream.
> -- Action: Will read in elements and store in array.
> -- Output: Array filled with elements.
> -------------------------------------------------------------------
>
> Index : IndexType;
> Element : ElementType;
>
> BEGIN -- Get_Array_Generic
>
> Index := List'Last; -- initialize array index to
> -- first subscript
This assignment is the only place this variable is mentioned in this
procedure. Since you're not doing anything with it, why not eliminate it?
>
> FOR Index IN List'RANGE LOOP
>
> Read (Item => Element); -- read elements into array
>
> -- store data into the array
>
> List (Index) := Element;
>
> END LOOP;
>
> END Get_Array_Generic;
Your code will look better to most of us if you use all lower case for
reserved words, and use underlines instead of case to separate words in
identifiers (Index_Type, not IndexType).
--
Jeff Carter
"It's all right, Taggart. Just a man and a horse being hung out there."
Blazing Saddles
next prev parent reply other threads:[~2003-07-11 1:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-10 22:01 HELP ! Problems with Get and Put in Generic Procedure Tanya
2003-07-10 22:37 ` Robert I. Eachus
2003-07-11 1:59 ` Jeffrey Carter [this message]
2003-07-15 1:40 ` Richard Riehle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox