comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de>
Subject: Re: renaming function result object inside loop
Date: Sun, 06 Sep 2009 22:09:06 +0200
Date: 2009-09-06T22:09:07+02:00	[thread overview]
Message-ID: <4aa416e3$0$30234$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <wccd464givl.fsf@shell01.TheWorld.com>

Robert A Duff wrote:
> Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de> writes:
> 
>> Is the following a spurious warning?
>>
>>    528.          loop
>>    529.             declare
>>    530.                Line : String renames LIO.Get_Line; --!
>>                                                 |
>>         >>> warning: renaming function result object is suspicious
>>         >>> warning: function "Get_Line" will be called only once
>>         >>> warning: suggest using an initialized constant object instead
>>
>> (Get_Line in fact seems to be called each time around the loop.)
> [...]
> In the first case, Get_Line is called "once" (i.e. when the
> declaration of Line is elaborated), whereas in the second case,
> Get_Line is called every time you say "Line".
> 
> Since a constant:
> 
>     Line : constant String := LIO.Get_Line;
> 
> has the same semantics as the first renaming,
> it seems preferable (and if you're lucky, the
> compiler will generate the same code).

Thanks for the clarification.  I was in FUD whether
Ada 2005 had changed things in agreement with the warning.
Which I clearly have misunderstood.

A thought about both confusing issues with renaming result
objects then:  If 'Result makes it into the language,
is renaming a function result an opportunity to
allow 'Result?

   Line : String renames LIO.Get_Line'Result;


Anyway,
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41286



      reply	other threads:[~2009-09-06 20:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-05 17:42 renaming function result object inside loop Georg Bauhaus
     [not found] ` <gpidncZaHuLEXT_XnZ2dnUVZ_j-dnZ2d@earthlink.com>
2009-09-05 20:27   ` Georg Bauhaus
2009-09-06 11:06 ` Oliver Kellogg
2009-09-06 16:03 ` Robert A Duff
2009-09-06 20:09   ` Georg Bauhaus [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox