comp.lang.ada
 help / color / mirror / Atom feed
* Pure Aspect on Library-Level Function
@ 2021-02-06 21:59 Jeffrey R. Carter
  2021-02-07 11:09 ` AdaMagica
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey R. Carter @ 2021-02-06 21:59 UTC (permalink / raw)


Given a library-level function in file f.ads

function F (Source : String) return String with Pure;

compiler G has no problem with this. Compiler O rejects it with the error msg

f.ads: Error: line 1 col 48 LRM:K.1(47), The Pure aspect is not allowed for a 
subprogram declaration

which is interesting, since Annex K is not normative. K.1 is Language-Defined 
Aspects, and K.1(47) is

47/3
  Pure
Side effects are avoided in the subprograms of a given package. See 10.2.1.

10.2.1 doesn't mention packages or subprograms, but rather compilation units 
(which subprograms may be), and it also talks about the effect of pragma Pure 
rather than aspect Pure. It does say

"A pragma Pure is used to specify that a library unit is declared pure, namely 
that the Pure aspect of the library unit is True"

which implies that library units have the Pure aspect, and since library units 
can be subprograms, such subprograms have the Pure aspect. It seems reasonable 
to presume that if something has an aspect, that aspect may be named in an 
aspect specification.

So I think the aspect is legal, but I'd like to know what others think.

-- 
Jeff Carter
"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41

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

* Re: Pure Aspect on Library-Level Function
  2021-02-06 21:59 Pure Aspect on Library-Level Function Jeffrey R. Carter
@ 2021-02-07 11:09 ` AdaMagica
  2021-02-11  2:53   ` Randy Brukardt
  0 siblings, 1 reply; 3+ messages in thread
From: AdaMagica @ 2021-02-07 11:09 UTC (permalink / raw)


Hm, I worked thru the RM and think compiler O(bject Ada?) is incorrect. But I'm not a language lawyer.
A subprogram ceclaration is a library unit.
10.2.1(17) A pragma Pure is used to specify that a library unit is declared pure, namely that the Pure aspect of the library unit is True
6.1(2) subprogram_declaration ::= 
    [overriding_indicator]
    subprogram_specification
        [aspect_specification];
Thus it seems the aspect can be defined via a pragma or via an aspect specification.

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

* Re: Pure Aspect on Library-Level Function
  2021-02-07 11:09 ` AdaMagica
@ 2021-02-11  2:53   ` Randy Brukardt
  0 siblings, 0 replies; 3+ messages in thread
From: Randy Brukardt @ 2021-02-11  2:53 UTC (permalink / raw)


I agree with Christoph. The very last Ada 202x AI (because it's the only one 
that I haven't finished yet) obsolesces all of the categorization pragmas, 
only defining the aspects in the core. So it will be crystal clear in the 
updated RM that the aspects apply to all compilation units (the pragmas 
having moved to Annex J). (All of the language-defined packages also have 
been changed to use aspects - that was a job I was working on today - I 
believe there will be only a single pragma left in the entire Ada library (a 
single "Elaborate_All", in Interfaces.Fortran).

This probably is just an oversight in compiler O.

BTW, these aspects are implemented in Janus/Ada (and have been for a while); 
if I'm reading the code right, they should should be allowed on any library 
unit. So Janus/Ada agrees with compiler G.

                            Randy.

"AdaMagica" <christ-usch.grein@t-online.de> wrote in message 
news:317ba71f-f049-4bbd-8da3-cc8dc1637eaan@googlegroups.com...
> Hm, I worked thru the RM and think compiler O(bject Ada?) is incorrect. 
> But I'm not a language lawyer.
> A subprogram ceclaration is a library unit.
> 10.2.1(17) A pragma Pure is used to specify that a library unit is 
> declared pure, namely that the Pure aspect of the library unit is True
> 6.1(2) subprogram_declaration ::=
>    [overriding_indicator]
>    subprogram_specification
>        [aspect_specification];
> Thus it seems the aspect can be defined via a pragma or via an aspect 
> specification. 


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

end of thread, other threads:[~2021-02-11  2:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06 21:59 Pure Aspect on Library-Level Function Jeffrey R. Carter
2021-02-07 11:09 ` AdaMagica
2021-02-11  2:53   ` Randy Brukardt

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