comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Proposal: Constructors, Assignment [LONG]
Date: Thu, 2 Jan 2003 13:44:42 -0600
Date: 2003-01-02T13:44:42-06:00	[thread overview]
Message-ID: <v195k5bkq6d535@corp.supernews.com> (raw)
In-Reply-To: auut21$aa0ff$1@ID-77047.news.dfncis.de

Dmitry A. Kazakov wrote in message ...
>Randy Brukardt wrote:
>I suppose it will be allowed for all types? Then it would be
interesting to
>know how it will work with by-value types:
>
>function Set_Bit (Value : Boolean) return Boolean is
>   Result : return Boollean := Value;
>begin
>   return Result;
>end Set_Bit;
>
>... provided that the result is an element of a packed array. Somehow,
>somewhere the "in-place" requirement have to be relaxed. I wonder how
many
>pages one will add to RM.

I don't know, it wasn't my idea. I'd suspect that by-copy types would be
handled by-copy, thus you couldn't tell if it was in-place or not.

>Then there will be much work required to deal with things like:
>
>function Make_Session (Count: Integer) return Internet_Session is
>begin
>   declare
>      Result1 : return Internet_Session (24);
>   begin
>      if ... then
>         return Result1;
>      end if;
>   end;
>   declare
>      Result2 : return Internet_Session (1000); - another size
>   begin
>      if ... then
>         return Result2;
>      end if;
>   end;
>   declare
>      Result3 : Internet_Session (10); -- I forgot "return"
>   begin
>      return Result3;
>   end;
>end Make_Session;


No, this is illegal. There can only be one result object declared. And
if there is one, returning anything else is illegal. So the declaration
of Result2 and the return of Result3 are illegal.

>I am not sure, but to determine whether there is only one result, could
be
>equivalent to halting problem. So some sort of run-time support will be
>well required to determine this. Or will it be classified as one more
bound
>error?


No, these are all compile-time checks. No run-time penalty at all.
Indeed, this is cheaper than Ada 95, where there is a run-time check
that the result of a function is "accessible". (And that check prevents
doing much useful with the function.)

         Randy.






  reply	other threads:[~2003-01-02 19:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-24 11:16 Proposal: Constructors, Assignment [LONG] Dmitry A. Kazakov
2002-12-26 22:11 ` Nick Roberts
2002-12-27 17:43   ` Dmitry A. Kazakov
2002-12-27 20:17     ` Randy Brukardt
2002-12-29 13:43       ` Dmitry A. Kazakov
2002-12-29 18:45         ` Nick Roberts
2002-12-30 12:23           ` Dmitry A. Kazakov
2002-12-30 15:14             ` Robert A Duff
2002-12-31 13:02               ` Dmitry A. Kazakov
2003-01-01  0:28                 ` Randy Brukardt
2003-01-01 14:13                   ` Dmitry A. Kazakov
2003-01-02 19:44                     ` Randy Brukardt [this message]
2003-01-03 13:21                       ` Dmitry A. Kazakov
2003-01-03 19:29                         ` Randy Brukardt
2003-01-03 20:50                       ` Robert A Duff
2003-01-04 12:53                         ` Dmitry A. Kazakov
2003-01-01  0:54         ` Randy Brukardt
2003-01-01 14:13           ` Dmitry A. Kazakov
2003-01-02 19:36             ` Randy Brukardt
2003-01-03 13:20               ` Dmitry A. Kazakov
replies disabled

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