comp.lang.ada
 help / color / mirror / Atom feed
* Question about pragma Restrictions(No_Recursion)
@ 2014-07-22 18:17 Peter Chapin
  2014-07-22 18:40 ` Robert A Duff
  2014-07-22 19:02 ` Jeffrey Carter
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Chapin @ 2014-07-22 18:17 UTC (permalink / raw)


Hello!

In section H.4 of the Ada RM No_Recursion is described by saying, "As
part of the execution of a subprogram the same subprogram is not invoked."

Paragraph 27 says, "Program execution is erroneous if pragma
Restrictions(No_Recursion) has been specified and a subprogram is
invoked as part of its own execution..."

I understand this to mean that the restriction, in this case, is really
a restriction on what the programmer does. The compiler is not obligated
to detect recursive constructs, however it could potentially (maybe)
simplify its runtime system on the assumption that no recursion exists.
If that assumption is wrong, well it's the programmer's problem.

This is to be contrasted with a number of the other restrictions listed
in H.4 that seem to put requirements on the compiler to explicitly
diagnose attempts to use the restricted feature.

Does that sound right?

Peter


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

* Re: Question about pragma Restrictions(No_Recursion)
  2014-07-22 18:17 Question about pragma Restrictions(No_Recursion) Peter Chapin
@ 2014-07-22 18:40 ` Robert A Duff
  2014-07-22 19:02 ` Jeffrey Carter
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 2014-07-22 18:40 UTC (permalink / raw)


Peter Chapin <PChapin@vtc.vsc.edu> writes:

> This is to be contrasted with a number of the other restrictions listed
> in H.4 that seem to put requirements on the compiler to explicitly
> diagnose attempts to use the restricted feature.
>
> Does that sound right?

Yes.

- Bob


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

* Re: Question about pragma Restrictions(No_Recursion)
  2014-07-22 18:17 Question about pragma Restrictions(No_Recursion) Peter Chapin
  2014-07-22 18:40 ` Robert A Duff
@ 2014-07-22 19:02 ` Jeffrey Carter
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Carter @ 2014-07-22 19:02 UTC (permalink / raw)


On 07/22/2014 11:17 AM, Peter Chapin wrote:
>
> I understand this to mean that the restriction, in this case, is really
> a restriction on what the programmer does. The compiler is not obligated
> to detect recursive constructs, however it could potentially (maybe)
> simplify its runtime system on the assumption that no recursion exists.
> If that assumption is wrong, well it's the programmer's problem.
>
> Does that sound right?

This seems similar to me to the restriction on potentially blocking operations 
in protected actions (ARM 9.5.1). Ideally, a compiler would arrange to raise 
Program_Error for every such case, and probably issue a compiler warning that 
this would happen. In practice, this requires things that are considered 
undesirable in most cases, and so is not required. (Pragma Detect_Blocking in 
H.5 can be used to force this if the compiler implements Annex H.)

In practice, most compilers detect direct invocation of a potentially blocking 
operation in a protected subprogram and ignore indirect invocations. So, for 
most compilers in most situations, this restriction is effectively meaningless.

Probably compilers implementing the No_Recursion restriction take a similar 
approach: if a subprogram calls itself directly, this is detected, but indirect 
recursion is not, and really it's up to the developer to decide if he wants to 
sneak in recursion anyway.

-- 
Jeff Carter
"I'm a lumberjack and I'm OK."
Monty Python's Flying Circus
54


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

end of thread, other threads:[~2014-07-22 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-22 18:17 Question about pragma Restrictions(No_Recursion) Peter Chapin
2014-07-22 18:40 ` Robert A Duff
2014-07-22 19:02 ` Jeffrey Carter

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