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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Gnat 2013 is out! Date: Fri, 31 May 2013 14:03:08 +0200 Organization: Tidorum Ltd Message-ID: References: <32d94173-533a-471e-95a0-abb73a6cdcc2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Trace: individual.net kSAx5C891fGKZDgaWoWx6gBRj+BNt93TnsrtFFXK9zg1FXqZk2 Cancel-Lock: sha1:DsbzjIwdKlQ3B4GI4l0qqqWDi4M= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: X-Original-Bytes: 3372 Xref: number.nntp.dca.giganews.com comp.lang.ada:181777 Date: 2013-05-31T14:03:08+02:00 List-Id: On 13-05-31 13:30 , Stefan.Lucks@uni-weimar.de wrote: > On Thu, 30 May 2013, Randy Brukardt wrote: > >> "Adam Beneschan" wrote in message >> >>> I've always wanted some kind of feature in Ada that would allow a >>> caller to provide a "dummy" for OUT parameters, without having to >>> declare a new variable. The compiler would allocate a temporary >>> object (and a separate one for each use of a "dummy") and then >>> discard it after the call. It wouldn't work well when parameter >>> types are unconstrained array or discriminant records, though. >> >> Hmm, that seems like a good idea to me. To me too, but only of the "nice to have" priority. >> But what would the syntax be? <> >> maybe? >> >> My_Proc (Obj1, Obj2, Result => <>); >> > > This has two issues: > > 1. This won't work if the type of Result is unconstrained, as, e.g., in > > procedure My_Proc(Obj1, Obj2: String; Result : String); This is probably a very rare case. > > 2. This would sometimes break overload resolution -- which procedure > should be called by "My_Proc (Obj1, Obj2, Result => <>);" if there > happens to be another procedure in scope, such as > > procedure My_Proc(Obj1, Obj2: String; Result : Unbounded_String); > > I'd suggest > > My_Proc (Obj1, Obj2, Result => String(1 .. 80)); > > or in general > > My_Proc (Obj1, Obj2, Result => type Name_of_Type); It seems more consistent with the present language to allow type qualification of the box, as in My_Proc (Obj1, Obj2, Result => Name_of_Type'(<>)); > as syntactic sugar for > > declare > Dummy : Name_Of_Type; > begin > My_Proc (Obj1, Obj2, Result => type Name_of_Type); You probable meant this to be: My_Proc (Obj1, Obj2, Result => Dummy); > end; If this proposal is taken up, I would like it to be extended with some mechanism by which the called subprogram can query if a given out parameter is actually a dummy <>, so that the subprogram can avoid computing a useless value into that out parameter. However, that could easily lead to distributed overhead. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .