From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9e02dc5f2c4718ab X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-18 15:34:51 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc04.POSTED!not-for-mail From: Stapler Subject: Re: Novice help with types and de-allocation. Newsgroups: comp.lang.ada References: <4519e058.0211180729.10b630dc@posting.google.com> User-Agent: Pan/0.11.3 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Comment-To: "Ted Dennison" Message-ID: NNTP-Posting-Host: 12.241.145.39 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc04 1037662490 12.241.145.39 (Mon, 18 Nov 2002 23:34:50 GMT) NNTP-Posting-Date: Mon, 18 Nov 2002 23:34:50 GMT Organization: AT&T Broadband Date: Mon, 18 Nov 2002 23:34:50 GMT Xref: archiver1.google.com comp.lang.ada:31076 Date: 2002-11-18T23:34:50+00:00 List-Id: On Mon, 18 Nov 2002 10:29:53 -0500, Ted Dennison wrote: > The "some reason" is that the object you are assigning Y into is of that > type. Unlike some other languages, in Ada you can't assign objects of > one type into objects of a another type, just because both types have > similar contents. You defined Int_Buffer and Buff_Out to be different > types, so they are truly considered unrelated types. Now that I reflect on it, it only makes sense. With a type declaration like I was trying to use, what's to stop me from attempting to read past the end of the Buffer array? If this was C, it would have been all hunky dory, but the Ada compiler wouldn't even let it past the compile stage. Now, I dont suppose that after entering my Read funtion I could do something like the following ... assuming I've did this in the spec... subtype Return_Buffer is Buffer; function Read( Y : in Buffer; Loc, Length : in Natural ) return Return_Buffer is Check : Natural begin Check := Loc + Length; if Loc > Buffer'Last then raise Exception; else if Length > Buffer'range then raise Exception; else if Check > Buffer'Last then raise Exception; else declare subtype Return_Buffer is Buffer(1..Length) begin -- process data here -- return Return_Buffer; end; end if; end Read; Now, I'm hoping that this deals with the underyling issue of this particular type declaration. However I'm still not sure if the compiler would let that fly. (Gonna try compiling it when I get home from work.) I suppose another option would be to create specific set of Input procedures that would check to make sure that the values are always within the range of the Buffer type. I've been humbled by GNAT. What's a psuedo-developer to do? Heh. Stapler