comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Legal usage of downward closures
Date: Thu, 16 Aug 2007 10:08:30 -0700
Date: 2007-08-16T10:08:30-07:00	[thread overview]
Message-ID: <1187284110.812863.280360@i38g2000prf.googlegroups.com> (raw)
In-Reply-To: <1187280678.505830.294720@a39g2000hsc.googlegroups.com>

On Aug 16, 9:11 am, mala...@magic.fr wrote:
> Hi,
>
> I have problems understanding the RAT05 section on downward closures.
>
> I thought that anonymous access to a sub-program, as parameter of a
> sub-program, would prevent local copies and further usage out of
> scope.
> Surprisingly, the following example compiles an runs (on GNAT GPL
> 2007).

The assignment statements are illegal.  Every "anonymous access type"
definition defines its own type; therefore Acc1 and Arg don't have the
same type, and neither of those types is the same as Acc2_Type.  GNAT
has a bug if it accepts them.

Furthermore, this would be illegal due to accessibility level rules:

    Acc2 := Acc_Type(Arg);

                               -- Adam




> package Pack is
>   procedure Store (Arg : access procedure);
>   procedure Call;
> end Pack;
>
> package body Pack is
>   Acc1 : access procedure;
>   type Acc_Type is access procedure;
>   Acc2 : Acc_Type;
>
>   procedure Store (Arg : access procedure) is
>   begin
>     Acc1 := Arg;  -- ILLEGAL
>     Acc2 := Arg;  -- ILLEGAL
>   end Store;
>   procedure Call is
>   begin
>     Acc1.all;
>     Acc2.all;
>   end Call;
>
> end Pack;




  reply	other threads:[~2007-08-16 17:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-16 16:11 Legal usage of downward closures malaise
2007-08-16 17:08 ` Adam Beneschan [this message]
2007-08-27 10:52   ` malaise
replies disabled

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