comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam@spam.com>
Subject: Re: Why was it done this way ?
Date: Thu, 27 Oct 2005 06:09:22 GMT
Date: 2005-10-27T06:09:22+00:00	[thread overview]
Message-ID: <ma_7f.2448$yX2.687@newsread2.news.pas.earthlink.net> (raw)
In-Reply-To: <S4X7f.13444$rE2.2101@fe10.lga>

Heimlich Manure wrote:

> Well, recursion would explain some but not all of it. Something like
> 
> task type T1;
> task body T1 is
>     MyGhost : T1;
 >
> is illegal. Meanwhile,

"T1" is not a subtype within T1.

> task type T1;
> type T1_Ptr is access T1;
> task body T1 is
>     MyGhostPtr : T1_Ptr;
> 
> is legal. But initializing MyGhostPtr can't be done, obviously, because T1
> is unmentionable within its own scope.

It's mentionable, but it is not a subtype name.

> Or even worse :
> 
> task type T1;
> type T1_Ghost is new T1;
> task body T1 is
>     MyGhostPtr : T1_Ghost;
> 
> Even this is legal !

T1_Ghost is a subtype name within T1.

Within T1, "T1" refers to the current instance of the type. ARM 9.1: "Within the 
declaration or body of a task unit, the name of the task unit denotes the 
current instance of the unit (see 8.6), rather than the first subtype of the 
corresponding task type (and thus the name cannot be used as a subtype_mark)." 
It turns out to be useful for an instance of a task type to be able to refer to 
itself. This is why these things don't behave the way you seem to expect.

The basic answer to your original question is that the language does not require 
compilers to be smart enough to detect infinite mutual recursion like this, any 
more than it requires that they detect infinite mutual recursion between 
subprograms.

-- 
Jeff Carter
"From this day on, the official language of San Marcos will be Swedish."
Bananas
28



  reply	other threads:[~2005-10-27  6:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-27  1:00 Why was it done this way ? Heimlich Manure
2005-10-27  2:30 ` jimmaureenrogers
2005-10-27  2:39   ` Heimlich Manure
2005-10-27  6:09     ` Jeffrey R. Carter [this message]
2005-10-27  6:46     ` Jean-Pierre Rosen
2005-10-27  2:46 ` Steve
2005-10-27  9:39 ` Georg Bauhaus
2005-10-27 15:07   ` Robert A Duff
replies disabled

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