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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c19e8df8a75221d0 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Q: Line_IO Date: Mon, 31 Aug 2009 21:08:03 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4a9b045a$0$31875$9b4e6d93@newsspool3.arcor-online.net> <1a4usf20z4mxa.1vct95fmrcs6h.dlg@40tude.net> <4a9c6320$0$31347$9b4e6d93@newsspool4.arcor-online.net> <4a9c687a$0$31341$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1251767283 4719 192.74.137.71 (1 Sep 2009 01:08:03 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 1 Sep 2009 01:08:03 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:LLUODgKQP4a/l8kDcvT/wIVMv6Y= Xref: g2news2.google.com comp.lang.ada:8084 Date: 2009-08-31T21:08:03-04:00 List-Id: Georg Bauhaus writes: > Georg Bauhaus wrote: >> procedure Print_2 (Item : String) is >> subtype Index is Stream_Element_Offset range >> Stream_Element_Offset(Item'First) >> .. Stream_Element_Offset(Item'Last); >> subtype XBytes is Stream_Element_Array (Index); >> Item_Bytes: XBytes; >> for Item_Bytes'Address use Item'Address; >> begin >> Stream_IO.Write (Stdout, Item_Bytes); >> Stream_IO.Write (Stdout, Separator_Bytes); >> end Print_2; > > *** line_io.ada old > --- line_io.ada new > *************** > *** 78,79 **** > --- 78,80 ---- > Item_Bytes: XBytes; > + pragma Import (Ada, Item_Bytes); > for Item_Bytes'Address use Item'Address; The Import is not strictly necessary, because Stream_Element_Array has no default initialization. But it's still good style -- it says, the declaration of Item_Bytes is not creating a new object, it's just overlaying an old one. If Item_Bytes had default inits (e.g. if it were an array of access values, which are default-initialized to null, or an array of records with some defaulted components), then the Import would be necessary. I think in that case, GNAT warns, because without the Import, the default inits will overwrite Item, which is certainly not what you want. - Bob