From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Q: Line_IO
Date: Mon, 31 Aug 2009 21:08:03 -0400
Date: 2009-08-31T21:08:03-04:00 [thread overview]
Message-ID: <wccws4jlbf0.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 4a9c687a$0$31341$9b4e6d93@newsspool4.arcor-online.net
Georg Bauhaus <see.reply.to@maps.futureapps.de> 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
next prev parent reply other threads:[~2009-09-01 1:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4a9b045a$0$31875$9b4e6d93@newsspool3.arcor-online.net>
2009-08-31 8:28 ` Q: Line_IO Martin
2009-08-31 10:05 ` Georg Bauhaus
2009-08-31 15:33 ` Anh Vo
2009-08-31 16:52 ` Georg Bauhaus
2009-08-31 18:39 ` Dmitry A. Kazakov
2009-08-31 22:51 ` Robert A Duff
2009-09-01 0:35 ` Georg Bauhaus
2009-08-31 23:56 ` Georg Bauhaus
2009-09-01 0:19 ` Georg Bauhaus
2009-09-01 1:08 ` Robert A Duff [this message]
2009-09-01 7:02 ` Ludovic Brenta
2009-09-01 9:55 ` Georg Bauhaus
2009-09-01 12:03 ` jonathan
[not found] ` <4a9e2c86$0$30235$9b4e6d93@newsspool1.arcor-online.net>
2009-09-02 8:47 ` Georg Bauhaus
2009-09-05 20:30 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox