comp.lang.ada
 help / color / mirror / Atom feed
* About procedures and functions in Ada Pure packages. Thanks!
@ 2022-08-15 10:31 Daniel Norte Moraes
  2022-08-18  1:12 ` Randy Brukardt
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Norte Moraes @ 2022-08-15 10:31 UTC (permalink / raw)


Hi! and Very Very Very Thanks!

I building and change some packages and I have some doubts
  about procedures and functions in Ada Pure packages.
I'm asking mainly the Ada Language Lawers. the Ada version is Ada2012.

 fact 1: Ada allow the compiler substitute a function with
  the result of this function.

?This is valid to functions with 'in out' or 'out' parameters ?
?This is valid to functions with 'not null access' parameters ?
?This is valid to procedures with 'in out' or 'out' parameters ?
?This is valid to procedures with 'not null access' parameters ?

?If they are replaced (on the second call onwards) by the result,
  will the 'in' 'in out' and 'not null access' parameters be updated
  if they are  changed within the function or procedure?

Very Very Very Thanks in Advance!
Best Wishes,
GrateFull,
Dani.

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

* Re: About procedures and functions in Ada Pure packages. Thanks!
  2022-08-15 10:31 About procedures and functions in Ada Pure packages. Thanks! Daniel Norte Moraes
@ 2022-08-18  1:12 ` Randy Brukardt
  2022-08-21 21:49   ` Daniel Norte Moraes
  0 siblings, 1 reply; 3+ messages in thread
From: Randy Brukardt @ 2022-08-18  1:12 UTC (permalink / raw)


"Daniel Norte Moraes" <danielcheagle@gmail.com> wrote in message 
news:e1f43654-dba6-46d7-bcd9-4aa79ed82f74n@googlegroups.com...
> Hi! and Very Very Very Thanks!
>
> I building and change some packages and I have some doubts
>  about procedures and functions in Ada Pure packages.
> I'm asking mainly the Ada Language Lawers. the Ada version is Ada2012.
>
> fact 1: Ada allow the compiler substitute a function with
>  the result of this function.
>
> ?This is valid to functions with 'in out' or 'out' parameters ?
> ?This is valid to functions with 'not null access' parameters ?
> ?This is valid to procedures with 'in out' or 'out' parameters ?
> ?This is valid to procedures with 'not null access' parameters ?

Yes, but there is a requirement that the input *values* are the same on both 
calls, and in the case of access types, everything reachable is the same on 
both calls. See 10.2.1(18/3) --  
http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-10-2-1.html#p18

Practically, compilers will exclude some or all of these cases.

> ?If they are replaced (on the second call onwards) by the result,
>  will the 'in' 'in out' and 'not null access' parameters be updated
>  if they are  changed within the function or procedure?

If the "in out" parameters are changed, then the values don't match on the 
second call, and the optimization isn't allowed. If the values are changed 
to the *same* value as original, the optimization would be allowed, but you 
couldn't tell whether or not the values were changed, so I think the 
question is moot in that case.

Again, I doubt that an actual compiler would try to optimize in such cases 
(too hard to prove that they're OK).

                                      Randy.


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

* Re: About procedures and functions in Ada Pure packages. Thanks!
  2022-08-18  1:12 ` Randy Brukardt
@ 2022-08-21 21:49   ` Daniel Norte Moraes
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Norte Moraes @ 2022-08-21 21:49 UTC (permalink / raw)


Em quarta-feira, 17 de agosto de 2022 às 22:12:24 UTC-3, Randy Brukardt escreveu:
> "Daniel Norte Moraes" <daniel...@gmail.com> wrote in message 
> news:e1f43654-dba6-46d7...@googlegroups.com...
> > Hi! and Very Very Very Thanks! 
> > 
> > I building and change some packages and I have some doubts 
> > about procedures and functions in Ada Pure packages. 
> > I'm asking mainly the Ada Language Lawers. the Ada version is Ada2012. 
> > 
> > fact 1: Ada allow the compiler substitute a function with 
> > the result of this function. 
> > 
> > ?This is valid to functions with 'in out' or 'out' parameters ? 
> > ?This is valid to functions with 'not null access' parameters ? 
> > ?This is valid to procedures with 'in out' or 'out' parameters ? 
> > ?This is valid to procedures with 'not null access' parameters ?
> Yes, but there is a requirement that the input *values* are the same on both 
> calls, and in the case of access types, everything reachable is the same on 
> both calls. See 10.2.1(18/3) -- 
> http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-10-2-1.html#p18 
> 
> Practically, compilers will exclude some or all of these cases.
> > ?If they are replaced (on the second call onwards) by the result, 
> > will the 'in' 'in out' and 'not null access' parameters be updated 
> > if they are changed within the function or procedure?
> If the "in out" parameters are changed, then the values don't match on the 
> second call, and the optimization isn't allowed. If the values are changed 
> to the *same* value as original, the optimization would be allowed, but you 
> couldn't tell whether or not the values were changed, so I think the 
> question is moot in that case. 
> 
> Again, I doubt that an actual compiler would try to optimize in such cases 
> (too hard to prove that they're OK). 
> 
> Randy.

Thanks Randy!

I'm satisfied.

Very Very Very GrateFull,
Best Wishes,
Dani.

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

end of thread, other threads:[~2022-08-21 21:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 10:31 About procedures and functions in Ada Pure packages. Thanks! Daniel Norte Moraes
2022-08-18  1:12 ` Randy Brukardt
2022-08-21 21:49   ` Daniel Norte Moraes

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