Re: Why was it done this way ?
- From: Robert A Duff <bobduff@xxxxxxxxxxxxxxxxxxxx>
- Date: 27 Oct 2005 11:07:14 -0400
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).
- Prev by Date: Re: Negative float problem
- Next by Date: Re: Negative float problem
- Previous by thread: Re: Why was it done this way ?
- Next by thread: Re: Isn't this in favour of Ada??