comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Gnat 2013 is out!
Date: Fri, 31 May 2013 17:07:37 -0500
Date: 2013-05-31T17:07:37-05:00	[thread overview]
Message-ID: <kob6vc$iil$1@loke.gir.dk> (raw)
In-Reply-To: alpine.DEB.2.02.1305311319150.13043@debian

<Stefan.Lucks@uni-weimar.de> wrote in message 
news:alpine.DEB.2.02.1305311319150.13043@debian...
>On Thu, 30 May 2013, Randy Brukardt wrote:
>> "Adam Beneschan" <adam@irvine.com> 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. 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);

That's not an issue, that's a feature. I would not expect this to work, 
because the "dummy" needs bounds/discriminants. <> means "default 
initialized", and if that is illegal, it should be illegal here, too. 
(Niklas had a suggested way to allow that, but honestly, I find that 
overkill. This is almost exclusively used to discard scalar results (at 
least in the cases I've encountered the need) and as such, I'd prefer it to 
be as simple as possible.

>   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);

That's ambiguous, of course. (And lousy subprogram design, too, but that's 
another story.) There's nothing new here, you get similar effects with 
class-wide objects, literals, and the like. This would resolve like a kind 
of super-literal. And keep in mind this is a convinient short-hand, not 
something that has to work. You can always declare an explicit dummy object 
if this doesn't work.

>I'd suggest
>
>         My_Proc (Obj1, Obj2, Result => String(1 .. 80));

That's ambiguous with type conversions, especially for discriminated types:
    My_Record(1) vs. My_Integer(1)
This is a "nice-to-have" feature, and making resolution much, much harder is 
not worth it. Additionally, I think it is important that this syntactically 
stands out -- it should not look anything like a normal parameter.

>or in general
>
>         My_Proc (Obj1, Obj2, Result => type Name_of_Type);

That's a bit better, but it doesn't evoke the usage of a dummy parameter at 
all. (And it would be hell on syntax error recovery algorithms.) My original 
message noted that the choice of syntax for this would be critical as to 
whether this would be adopted (because readability is so important to Ada, 
and this is not a critical feature). I toned that down when I thought of 
using <> for the parameter, because it seemed like a sensible choice.

Unless the syntax makes it pretty obvious that this is a dummy, discarded 
parameter, this idea is going nowhere. (And it might very well go nowhere 
even if the syntax is perfect.)

                                       Randy.


                                      Randy.




  parent reply	other threads:[~2013-05-31 22:07 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-29 13:36 Gnat 2013 is out! J-P. Rosen
2013-05-29 15:03 ` Simon Wright
2013-05-29 16:13   ` Simon Wright
2013-05-29 22:39     ` Randy Brukardt
2013-05-30  2:01       ` Adam Beneschan
2013-05-30  8:01         ` Bill Findlay
2013-05-30 23:09           ` Dennis Lee Bieber
2013-05-31  5:02             ` J-P. Rosen
2013-05-31 18:35             ` Bill Findlay
2013-05-30 10:39         ` Simon Wright
2013-05-30 16:21           ` Adam Beneschan
2013-05-30 19:53         ` Randy Brukardt
2013-05-31  7:41           ` Dmitry A. Kazakov
2013-05-31 11:30           ` Stefan.Lucks
2013-05-31 12:03             ` Niklas Holsti
2013-05-31 22:07             ` Randy Brukardt [this message]
2013-06-01 11:51               ` Georg Bauhaus
2013-06-03 14:52                 ` Adam Beneschan
2013-06-04 17:42                   ` Wesley Pan
2013-06-04 18:34                     ` Adam Beneschan
2013-06-04 19:00                       ` Wesley Pan
2013-06-05 15:40                     ` Eryndlia Mavourneen
2013-06-11  2:39                   ` Randy Brukardt
2013-06-11  6:31                     ` Georg Bauhaus
2013-06-19 21:57                       ` Randy Brukardt
2013-05-30  0:31 ` Dennis Lee Bieber
2013-05-31 16:12 ` dptrash
2013-06-01  5:10   ` Stephen Leake
2013-06-01  6:00   ` Per Sandberg
2013-06-01  6:46   ` J-P. Rosen
2013-06-01 15:22     ` Bill Findlay
2013-08-27 14:08   ` Yannick Duchêne (Hibou57)
2013-08-27 20:05     ` wilson
2013-08-27 22:59       ` Dennis Lee Bieber
2013-08-28  7:35         ` Dmitry A. Kazakov
2013-08-28 23:39           ` Dennis Lee Bieber
2013-06-07  2:41 ` gautier_niouzes
2013-06-07 15:52 ` mjsilva
2013-06-07 20:15   ` Dmitry A. Kazakov
2013-06-09 18:51     ` MatthiasR
2013-06-08  6:22   ` Simon Wright
2013-06-08 23:23     ` mjsilva
2013-06-10 11:07   ` Rego, P.
2013-06-13 13:30     ` Rego, P.
2013-06-17  6:35       ` Jacob Sparre Andersen
2013-06-22  8:17         ` MatthiasR
2014-03-18  0:04           ` Rego, P.
2013-06-11  7:52 ` Maciej Sobczak
2013-06-11  9:35   ` J-P. Rosen
2013-06-11 12:09   ` John Doe
2013-06-12  7:58 ` Maciej Sobczak
2013-06-12 11:01   ` G.B.
2013-06-12 20:01   ` Robert A Duff
2013-06-12 20:36     ` Georg Bauhaus
2013-06-13  7:38     ` Maciej Sobczak
replies disabled

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