Version 1.1 of acs/ac-00227.txt
!standard 6.5(2.1/2) 12-01-21 AC95-00227/00
!class Amendment 12-01-21
!status received no action 12-01-21
!status received 11-12-15
!subject Return null
!summary
!appendix
From: Martin Dowie
Sent: Thursday, December 15, 2011 2:23 PM
I've been writing up the GoF Patterns in Ada2012 (13 of 23 done so far!) and
have noticed a number of times when I've found myself writing extended return
statements that do nothing:
function Create return Application is
begin
return Result : Application do
null;
end return;
end Create;
It's only a bit of "syntactic sugar" but I think it would be nice to allow:
function Create return Application is
begin
return Result : Application is null;
end Create;
And/or to allow a function expression to be used, e.g.:
function Create return Application is
(null);
which would implicitly expand into the original.
***************************************************************
From: Randy Brukardt
Sent: Thursday, December 15, 2011 2:27 PM
Umm, you do know that the entire "do" part is optional, right? (Note the square
brackets around that part in the syntax of 6.5(2.1/2)).
What's wrong with:
function Create return Application is
begin
return Result : Application;
end Create;
which is perfectly legal today??
***************************************************************
From: Gary Dismukes
Sent: Thursday, December 15, 2011 4:16 PM
...
> It's only a bit of "syntactic sugar" but I think it would be nice to
> allow:
>
> function Create return Application is
> begin
> return Result : Application is null;
> end Create;
There already is a shorthand (even shorter than your suggestion:-):
function Create return Application is
begin
return Result : Application;
end Create;
> And/or to allow a function expression to be used, e.g.:
>
> function Create return Application is
> (null);
>
> which would implicitly expand into the original.
Ada 2012 expression functions couldn't really be used that way, because that
form already has a meaning, which is to return the value null (requires an
access type result, of course).
***************************************************************
From: Martin Dowie
Sent: Thursday, December 15, 2011 4:40 PM
Thanks Gary, I'd never see this before!
***************************************************************
From: Martin Dowie
Sent: Thursday, December 15, 2011 4:51 PM
Sorry Randy, I hadn't picked up on that at all...in the 6 years it seems to have
been available!
***************************************************************
From: Randy Brukardt
Sent: Thursday, December 15, 2011 8:43 PM
Well, I have to admit that this has to be in the top 5 of "easy to provide
feature requests". :-) The only question was whether I missed some subtlety in
your request -- I guess not.
***************************************************************
From: Bob Duff
Sent: Sunday, December 18, 2011 10:09 AM
> There already is a shorthand (even shorter than your suggestion:-):
>
> function Create return Application is
> begin
> return Result : Application;
> end Create;
Right.
Another thing that might work, depending on what Application looks like is:
return (others => <>);
or:
return Application'(others => <>);
***************************************************************
Questions? Ask the ACAA Technical Agent