comp.lang.ada
 help / color / mirror / Atom feed
* Why formal_part is not a declarative region?
@ 2013-11-01  6:57 Maxim Reznik
  2013-11-01 16:06 ` Adam Beneschan
  0 siblings, 1 reply; 2+ messages in thread
From: Maxim Reznik @ 2013-11-01  6:57 UTC (permalink / raw)


Hi all,

I read ARM "8.1 Declarative Region" for good sleep.

I wounder why formal_part neither access_to_subprogram_definition isn't included in list of declarative regions?

Consider next example:

type T is
 access function (A : Integer) return
 access function (A : Float) return Boolean;

According to ARM there is declarative region for T. It contains two declaration of A, but this is illegal.

What is wrong?

-- 
Maxim Reznik

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

* Re: Why formal_part is not a declarative region?
  2013-11-01  6:57 Why formal_part is not a declarative region? Maxim Reznik
@ 2013-11-01 16:06 ` Adam Beneschan
  0 siblings, 0 replies; 2+ messages in thread
From: Adam Beneschan @ 2013-11-01 16:06 UTC (permalink / raw)


On Thursday, October 31, 2013 11:57:25 PM UTC-7, Maxim Reznik wrote:
> Hi all,
> 
> I read ARM "8.1 Declarative Region" for good sleep.
> 
> I wounder why formal_part neither access_to_subprogram_definition isn't included in list of declarative regions?
> 
> Consider next example:
> 
> type T is
>  access function (A : Integer) return
>    access function (A : Float) return Boolean;
> 
> According to ARM there is declarative region for T. It contains two declaration of A, but this is illegal.
> 
> What is wrong?

I'm not sure if anything is "wrong", except that I tried your construct on two compilers and neither one reported an error.  But from the looks of things in the RM, this should be an error.  

If the parameter names were accessible to some other code, then we'd certainly want to make it an error, to avoid confusion.  Consider this entry family case:

    protected body PT is
        entry E1 (for X in 1..5) (X : in out Integer) when True is
        begin
            ...
        end E1;
    end PT;

Obviously, this should be illegal (although at least one compiler doesn't produce an error message), since using X inside the entry body would be ambiguous.  If subprogram formal parts were made into their own declarative regions, it would make it complicated to make code like this illegal.  So it seems reasonable to say that both X declarations are part of the same declarative region, and are therefore illegal.

Access-to-subprogram declarations are a little different, since as far as I know, the parameter names are dummies--they can't be used for anything.  (I could be wrong, especially if they can now be used in predicates.)  However, the syntax for access-to-subprogram declarations uses the same syntax rules and syntactic category names as regular subprogram declarations, and I think it would be a pain to try to tweak the rules so that parameter lists in access-subprogram declarations and other kinds of declarations are treated differently.  Clearly there's no pressing need to do so, since there's almost no benefit to allowing the two parameter names to be the same in your example declaration.  

                               -- Adam

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

end of thread, other threads:[~2013-11-01 16:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01  6:57 Why formal_part is not a declarative region? Maxim Reznik
2013-11-01 16:06 ` Adam Beneschan

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