Re: Why was it done this way ?



Georg Bauhaus <bauhaus@xxxxxxxxxxxxx> writes:

> I think it might be difficult in general to detect mutual
> recursion, but IANALL ...

It is a language design principle that the compiler should be able to
detect legality errors by looking only at the current compilation unit,
and things it depends upon semantically. In particular, the compiler
shouldn't have to look at other package bodies. The mutually recursive
tasks could be separately compiled. There are a few exceptions to
this principle (see "Post-Compilation Rules" in the RM). These are
deliberately kept to a minimum.

As JPR pointed out, the goal of the rule (that the task type name
denotes the task when inside it) is _not_ to prevent recursion.
It is simply a convenient way to refer to the current instance.
The same rule applies to records and generic units. The language
could have been designed to have special syntax for this case
(something like "this T1").

Anyway, recursion (mutual or otherwise) of tasks is useful (in rare cases),
so it would be annoying if it were forbidden. It might be nice
to detect _infinite_ recursion of tasks (or of procedures, for
that matter), but that's impossible in the general case.

I believe GNAT is capable of printing a warning on _some_ infinite
recursions (of procedures).

- Bob
.



Relevant Pages

  • Re: made it to page 4 of gforth tutorial
    ... support recursion other than tail recursion, ... Neither standard specifies (or ever could ... That's solely up to the compiler vendor and the end ... specifics of the target, I'm going to pretend that I can do anything I ...
    (comp.lang.forth)
  • Re: made it to page 4 of gforth tutorial
    ... support recursion other than tail recursion, ... follow the C standard. ... have trouble calling that a C compiler. ... fully support recursion. ...
    (comp.lang.forth)
  • Re: Treeviews
    ... Yes, MF supports Recursion, local-storage, and MANY other extensions (so marked ... > if you have a Micro Focus cobol compiler, ... move 1 to tree-pointer ... > like wise, entry points are allowed, supported and well documented. ...
    (comp.lang.cobol)
  • Re: whats wrong with a pic ?
    ... They are just fine for an assembly programmer who is used to ... A lot of 8 and 16 bit MCU compilers don't have recursion switched on by ... While recursion is very seldom the right way to approach a problem on a small micro, the fact that recursion is not supported shows the processor is not well suited to C, since it is missing one or both of a proper return stack and a fast access data stack for local variables. ... These are not essential for making a C compiler (in the c.a.e. ...
    (comp.arch.embedded)
  • Re: Question: Overflow
    ... I know that this is probably compiler and implementation dependent and that this is a standard c discussion group but can someone point me in the right direction or just answer? ... It never reaches the printf in a because it always recurses before it gets to it, and it never reaches the printf in main because a never returns. ... I would suggest reading the chapters on recursion in your text book, including anything that mentions "mutually recursive functions" or "mutual recursion". ...
    (comp.lang.c)