comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Ada 2012: In-out parameters for functions
Date: Tue, 07 May 2013 05:59:49 +0200
Date: 2013-05-07T05:59:49+02:00	[thread overview]
Message-ID: <op.wwo31ziqule2fv@cardamome> (raw)
In-Reply-To: aumqbiFf76eU1@mid.individual.net

Le Sun, 05 May 2013 12:24:50 +0200, Niklas Holsti  
<niklas.holsti@tidorum.invalid> a écrit:

> On 13-05-04 02:29 , Randy Brukardt wrote:
>
>> I agree that named notation should include the direction of the  
>> parameter,
>> but again its way too late to fix. The best syntax would have been
>>      Proc (In_Param => A, Out_Param <= B, In_Out_Param <=> C);
>> but unfortunately "<=" is used for less-than-or-equals and trying to  
>> use it
>> in this context would be ambiguous.
>>
>> So the best practical syntax would be:
>>      Proc (In_Param -> A, Out_Param <- B, In_Out_Param <-> C);
>
> How about reusing the mode keywords:
>
>    Proc (
>       In_Param  => in A,
>       Out_Param => out B,
>       In_Out_Param => in out C);
>

As another option if you are not afraid about a lot of restrictions, there  
is one which won't make parameters modes visible, but which will surely  
catch any erroneous assumptions on these, due to an assertion on the  
effect of calling it, failing sooner or later:


     -- SPARK way to solve the issue
     -- and to make explicit what it do.

     procedure P
       (A :    out T;
        B : in out T;
        C : in     T);
     --# derives
     --#    A from B, C &
     --#    B from B, C ;


As a bonus, this could even catch far more errors than simply reminding  
parameter modes :-P … but forget about generic packages [1], subtypes [2]  
and many other things.

[1]: library level generic sub‑programs is OK, but this has the  
implication a generic cannot defines types, constants, etc.
[2]: the last time I tried it, only type‑new was allowed, not sure if it's  
still the same now; may check later.

-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University


  parent reply	other threads:[~2013-05-07  3:59 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 16:28 Ada 2012: In-out parameters for functions dptrash
2013-05-01 17:27 ` Shark8
2013-05-01 19:04 ` Yannick Duchêne (Hibou57)
2013-05-01 19:37   ` Dmitry A. Kazakov
2013-05-01 19:58     ` Yannick Duchêne (Hibou57)
2013-05-02  6:41       ` Dmitry A. Kazakov
2013-05-02  7:11         ` Yannick Duchêne (Hibou57)
2013-05-01 23:37 ` Peter C. Chapin
2013-05-03 10:48 ` anon
2013-05-03 11:04   ` Simon Clubley
2013-05-03 11:32   ` Simon Wright
2013-05-03 11:42   ` Yannick Duchêne (Hibou57)
2013-05-03 11:54     ` Yannick Duchêne (Hibou57)
2013-05-03 23:29       ` Randy Brukardt
2013-05-04  1:02         ` Adam Beneschan
2013-05-05  5:16           ` Randy Brukardt
2013-05-05 10:24         ` Niklas Holsti
2013-05-05 11:11           ` Yannick Duchêne (Hibou57)
2013-05-05 12:52             ` Bill Findlay
2013-05-05 15:09               ` Niklas Holsti
2013-05-05 19:23                 ` Yannick Duchêne (Hibou57)
2013-05-05 20:37                   ` Niklas Holsti
2013-05-07  0:30                 ` Randy Brukardt
2013-05-07  2:36                   ` Yannick Duchêne (Hibou57)
2013-05-05 19:45               ` Yannick Duchêne (Hibou57)
2013-05-06 15:40               ` Adam Beneschan
2013-05-06 16:17                 ` Bill Findlay
2013-05-06 16:47                   ` Adam Beneschan
2013-05-06 18:43                     ` Bill Findlay
2013-05-07  0:07                     ` Dennis Lee Bieber
2013-05-07  2:34                       ` Yannick Duchêne (Hibou57)
2013-05-07  0:26             ` Randy Brukardt
2013-05-06 15:26           ` Adam Beneschan
2013-05-07  0:36             ` Randy Brukardt
2013-05-07  3:59           ` Yannick Duchêne (Hibou57) [this message]
2013-05-07  4:13             ` Yannick Duchêne (Hibou57)
2013-05-07 11:52             ` Yannick Duchêne (Hibou57)
2013-05-03 11:45   ` AdaMagica
2013-05-03 23:54     ` Randy Brukardt
2013-05-04  6:58       ` J-P. Rosen
2013-05-04  7:21         ` Dmitry A. Kazakov
2013-05-04 17:58           ` J-P. Rosen
2013-05-04  7:40         ` Yannick Duchêne (Hibou57)
2013-05-04  8:05           ` Simon Wright
2013-05-04 17:55           ` J-P. Rosen
2013-05-04  0:40   ` Keith Thompson
replies disabled

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