comp.lang.ada
 help / color / mirror / Atom feed
* relax double parens in expression_function_declaration?
@ 2017-02-20 20:52 Stephen Leake
  2017-02-20 21:16 ` Simon Wright
  2017-02-20 22:03 ` Randy Brukardt
  0 siblings, 2 replies; 9+ messages in thread
From: Stephen Leake @ 2017-02-20 20:52 UTC (permalink / raw)


Recent GNAT allows this:

   type Result is record
      A : Integer;
      B : Integer;
   end record;

   function Key return Result is
     (A => 1,
      B => 2);

However, I can't find a rule in the ARM that allows it.
ARM 6.8 says:

   expression_function_declaration ::=
        [overriding_indicator]
        function_specification is
            (expression)
            [aspect_specification];

This requires double parens:

   function Key return Result is
     ((A => 1,
       B => 2));

ARM 4.5.7(7) gives permission to remove the double parens for conditional_expression; is there a similar rule or AI for aggregates?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-20 20:52 relax double parens in expression_function_declaration? Stephen Leake
@ 2017-02-20 21:16 ` Simon Wright
  2017-02-20 22:11   ` Randy Brukardt
  2017-02-20 22:03 ` Randy Brukardt
  1 sibling, 1 reply; 9+ messages in thread
From: Simon Wright @ 2017-02-20 21:16 UTC (permalink / raw)


Stephen Leake <stephen_leake@stephe-leake.org> writes:

> However, I can't find a rule in the ARM that allows it.
> ARM 6.8 says:
>
>    expression_function_declaration ::=
>         [overriding_indicator]
>         function_specification is
>             (expression)
>             [aspect_specification];

Actually there is, I think, a typo: the first semicolon in
http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-6-8.html#p2 should
be a pipe, '|'.

> This requires double parens:
>
>    function Key return Result is
>      ((A => 1,
>        B => 2));
>
> ARM 4.5.7(7) gives permission to remove the double parens for
> conditional_expression; is there a similar rule or AI for aggregates?

AARM 4.5.7(7.j),
http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-4-5-7.html#p7.j,
says

   The English-language rule applies in all places that could surround
   an expression with parentheses, including pragma arguments, type
   conversion and qualified expression operands, and array index
   expressions.

but it's far from clear what that means, & if it applies to aggregates,
why that couldn't have been made explicit in (7) in the first place!


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-20 20:52 relax double parens in expression_function_declaration? Stephen Leake
  2017-02-20 21:16 ` Simon Wright
@ 2017-02-20 22:03 ` Randy Brukardt
  2017-02-21 12:15   ` Stephen Leake
  1 sibling, 1 reply; 9+ messages in thread
From: Randy Brukardt @ 2017-02-20 22:03 UTC (permalink / raw)


"Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
news:864b4b14-5c42-4ddc-92ee-ad76ce2be159@googlegroups.com...
> Recent GNAT allows this:
>
>   type Result is record
>      A : Integer;
>      B : Integer;
>   end record;
>
>   function Key return Result is
>     (A => 1,
>      B => 2);
>
> However, I can't find a rule in the ARM that allows it.

You're looking at the wrong version of the RM, then: that was fixed in the 
Corrigendum. Since "Corrigendum" means "bug-fixes" in ISO-speak, it's silly 
to use the original version. Find the Corrigendum version of the RM on 
Ada-Auth.org:  http://www.ada-auth.org/standards/ada12_w_tc1.html. (Or from 
the main ARM page: http://www.ada-auth.org/arm.html). Since there are fixed 
scattered throughout the manual, one can never guess whether changes were 
made to a particular rule.

You can also find the working version of the RM on Ada-auth.org, which 
includes everything that's been approved for the next version of Ada 
(whenever that will be); that includes more bug fixes as well as some new 
features:
http://www.ada-auth.org/standards/ada2x.html (Whether or not any compiler 
supports the new stuff is of course up to them; I know GNAT does support 
some of the new features.)

                            Randy.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-20 21:16 ` Simon Wright
@ 2017-02-20 22:11   ` Randy Brukardt
  2017-02-21 15:38     ` Simon Wright
  0 siblings, 1 reply; 9+ messages in thread
From: Randy Brukardt @ 2017-02-20 22:11 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:lybmtwk1gd.fsf@pushface.org...
...
> Actually there is, I think, a typo: the first semicolon in
> http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-6-8.html#p2 should
> be a pipe, '|'.

???. The declaration ends with a semicolon, and since the next line starts 
with a pipe, it's clearly not missing.

...
>> ARM 4.5.7(7) gives permission to remove the double parens for
>> conditional_expression; is there a similar rule or AI for aggregates?
>
> AARM 4.5.7(7.j),
> http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-4-5-7.html#p7.j,
> says
>
>   The English-language rule applies in all places that could surround
>   an expression with parentheses, including pragma arguments, type
>   conversion and qualified expression operands, and array index
>   expressions.
>
> but it's far from clear what that means, & if it applies to aggregates,
> why that couldn't have been made explicit in (7) in the first place!

That rule doesn't apply to aggregates; we have an explicit rule in 6.8 for 
the case of aggregates in expression functions. Double parens are required 
for aggregates in those other contexts (most of which don't allow aggregates 
anyway - they're illegal for other reasons), or, like qualified exprssions, 
they also have explicit rules allowing the aggregate without double parens.

Mainly what the 4.5.7(7) means is that we didn't want to hack the Ada 
grammar enough to explicitly eliminate the double parens. (It's not that 
hard to do -- I did it in the Janus/Ada grammar -- but it does require 
extensive grammar changes). So we just said that they don't happen for 
conditional expressions (and quantified expressions -- interestingly, 
raise_expressions are handled explicitly).

                                        Randy.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-20 22:03 ` Randy Brukardt
@ 2017-02-21 12:15   ` Stephen Leake
  2017-02-21 20:03     ` Randy Brukardt
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Leake @ 2017-02-21 12:15 UTC (permalink / raw)


On Monday, February 20, 2017 at 4:03:24 PM UTC-6, Randy Brukardt wrote:
> "Stephen Leake" wrote:
> > Recent GNAT allows this:
> >
> >   type Result is record
> >      A : Integer;
> >      B : Integer;
> >   end record;
> >
> >   function Key return Result is
> >     (A => 1,
> >      B => 2);
> >
> > However, I can't find a rule in the ARM that allows it.
> 
> You're looking at the wrong version of the RM, then: that was fixed in the 
> Corrigendum. 

Ah. I was looking at the info version; I guess it's time to update that to include the Corrigendum.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-20 22:11   ` Randy Brukardt
@ 2017-02-21 15:38     ` Simon Wright
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Wright @ 2017-02-21 15:38 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> "Simon Wright" <simon@pushface.org> wrote in message 
> news:lybmtwk1gd.fsf@pushface.org...
> ...
>> Actually there is, I think, a typo: the first semicolon in
>> http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-6-8.html#p2 should
>> be a pipe, '|'.
>
> ???. The declaration ends with a semicolon, and since the next line
> starts with a pipe, it's clearly not missing.

Sorry about that. I hadn't realized that Stephe was looking at the
original 2012 manual, so confused myself into thinking he'd missed the
second (aggregate-related) part of the syntax.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-21 12:15   ` Stephen Leake
@ 2017-02-21 20:03     ` Randy Brukardt
  2017-02-22 13:12       ` Georg Bauhaus
  0 siblings, 1 reply; 9+ messages in thread
From: Randy Brukardt @ 2017-02-21 20:03 UTC (permalink / raw)


"Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
news:55282a80-cc54-4901-9cfd-1a9ee273be1b@googlegroups.com...
...
>> You're looking at the wrong version of the RM, then: that was fixed in 
>> the
>> Corrigendum.
>
> Ah. I was looking at the info version; I guess it's time to update that to 
> include the Corrigendum.

Well, that was a year ago when the Corrigendum was approved, but who's 
counting? ;-) I probably should have asked you to update it then, as I 
didn't have anything to link to for the info version (and thus just removed 
it).

                                  Randy.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-21 20:03     ` Randy Brukardt
@ 2017-02-22 13:12       ` Georg Bauhaus
  2017-02-22 23:00         ` Randy Brukardt
  0 siblings, 1 reply; 9+ messages in thread
From: Georg Bauhaus @ 2017-02-22 13:12 UTC (permalink / raw)


Randy Brukardt <randy@rrsoftware.com> wrote:
> "Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
> news:55282a80-cc54-4901-9cfd-1a9ee273be1b@googlegroups.com

>> Ah. I was looking at the info version; I guess it's time to update that to 
>> include the Corrigendum.
> 
> Well, that was a year ago when the Corrigendum was approved, but who's 
> counting? ;-) I probably should have asked you to update it then, as I 
> didn't have anything to link to for the info version (and thus just removed 
> it).

<remark snide >Wouldn't it be about time to demonstrate how old hands
 will do an integration build for Ada over the internet 8-> </>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: relax double parens in expression_function_declaration?
  2017-02-22 13:12       ` Georg Bauhaus
@ 2017-02-22 23:00         ` Randy Brukardt
  0 siblings, 0 replies; 9+ messages in thread
From: Randy Brukardt @ 2017-02-22 23:00 UTC (permalink / raw)



"Georg Bauhaus" <nonlegitur@futureapps.invalid> wrote in message 
news:o8k2nq$c0j$1@dont-email.me...
> Randy Brukardt <randy@rrsoftware.com> wrote:
>> "Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message
>> news:55282a80-cc54-4901-9cfd-1a9ee273be1b@googlegroups.com
>
>>> Ah. I was looking at the info version; I guess it's time to update that 
>>> to
>>> include the Corrigendum.
>>
>> Well, that was a year ago when the Corrigendum was approved, but who's
>> counting? ;-) I probably should have asked you to update it then, as I
>> didn't have anything to link to for the info version (and thus just 
>> removed
>> it).
>
> <remark snide >Wouldn't it be about time to demonstrate how old hands
> will do an integration build for Ada over the internet 8-> </>

I can generate the info results from the tools I have, but I don't use it 
myself so I can't test it for correctness (that's more of a problem if I 
changed the driver interface; Stephen created the info driver and I can only 
guess on how to change things). I don't really want to post untested stuff; 
someone might want me to fix it!

As I said, I probably should have asked Stephen at the time to generate it 
and/or check one I generated. I suspect, though, that I was just happy to 
get that particular project off of my desk (it's time-consuming, boring work 
that is easy to screw up, especially the PDF creation).

                                          Randy.



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-02-22 23:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-20 20:52 relax double parens in expression_function_declaration? Stephen Leake
2017-02-20 21:16 ` Simon Wright
2017-02-20 22:11   ` Randy Brukardt
2017-02-21 15:38     ` Simon Wright
2017-02-20 22:03 ` Randy Brukardt
2017-02-21 12:15   ` Stephen Leake
2017-02-21 20:03     ` Randy Brukardt
2017-02-22 13:12       ` Georg Bauhaus
2017-02-22 23:00         ` Randy Brukardt

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