comp.lang.ada
 help / color / mirror / Atom feed
* Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
@ 2013-12-05  3:58 Rod Kay
  2013-12-05  6:50 ` Shark8
  2013-12-05  9:51 ` Georg Bauhaus
  0 siblings, 2 replies; 9+ messages in thread
From: Rod Kay @ 2013-12-05  3:58 UTC (permalink / raw)


Hi all,

   Would anyone know the reason for this ? 

   Bounded strings would appear to be useful for DSA at least. As a test, I copied/renamed the relevant bounded string packages and made them Pure and found no obvious problems (a simple test compiled and ran ok).


regards,
Rod.


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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-05  3:58 Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ? Rod Kay
@ 2013-12-05  6:50 ` Shark8
  2013-12-05  8:16   ` Rod Kay
  2013-12-05  9:51 ` Georg Bauhaus
  1 sibling, 1 reply; 9+ messages in thread
From: Shark8 @ 2013-12-05  6:50 UTC (permalink / raw)


On Wednesday, December 4, 2013 8:58:46 PM UTC-7, Rod Kay wrote:
> Hi all,
> 
> 
> 
>    Would anyone know the reason for this ? 
> 
> 
> 
>    Bounded strings would appear to be useful for DSA at least. As a test, I copied/renamed the relevant bounded string packages and made them Pure and found no obvious problems (a simple test compiled and ran ok).

Does DSA = Distributed System Application?
Another package that would be nice in a different categorization is Ada.Tags (it would be nice to be able to use them across DSA partitions and in remote-call interfaces).



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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-05  6:50 ` Shark8
@ 2013-12-05  8:16   ` Rod Kay
  0 siblings, 0 replies; 9+ messages in thread
From: Rod Kay @ 2013-12-05  8:16 UTC (permalink / raw)


On Thursday, 5 December 2013 17:50:57 UTC+11, Shark8  wrote:
> 
> Does DSA = Distributed System Application?

Yes .. or Distributed Systems Annex ... much the same thing.

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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-05  3:58 Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ? Rod Kay
  2013-12-05  6:50 ` Shark8
@ 2013-12-05  9:51 ` Georg Bauhaus
  2013-12-05 20:17   ` Randy Brukardt
  2013-12-06  4:28   ` Rod Kay
  1 sibling, 2 replies; 9+ messages in thread
From: Georg Bauhaus @ 2013-12-05  9:51 UTC (permalink / raw)


On 05.12.13 04:58, Rod Kay wrote:
> Hi all,
>
>     Would anyone know the reason for this ?

Two possible reasons, guessing:

1) pragma Pure being >= Ada 95, and compatibility,

2) an implementation may choose to use pointers internally.



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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-05  9:51 ` Georg Bauhaus
@ 2013-12-05 20:17   ` Randy Brukardt
  2013-12-06  3:03     ` Brad Moore
  2013-12-06  4:36     ` Rod Kay
  2013-12-06  4:28   ` Rod Kay
  1 sibling, 2 replies; 9+ messages in thread
From: Randy Brukardt @ 2013-12-05 20:17 UTC (permalink / raw)


We re-analyzed all of the existing packages for Ada 2005, and changed the 
categorization of some of them. The details can be found in AI95-0362-1 
(http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00362.txt).

There is a listing of every predefined package in that AI. Here's the entry 
for Bounded strings:

Ada.Strings.Bounded -- A.4.4; Preelaborate
  This package contains no state, no dependence on non-pure units, no
  other items that prevent the package from being pure, and does not declare
  any types that would be a problem for Annex E, so it could be declared 
pure.
  But it's large and complex, and many of the operations are not 
conceptually
  pure (they do in-place updates), so no change is recommended.

This admittedly does not seem very satisfying. We didn't redo this exercise 
for Ada 2012, the only change we made was to make Stream_IO preelaborated so 
that loggers and the like can be written. (It's not practical to make the 
full Text_IO preelaborated [the obvious approach is not task-safe], and 
there was no agreement on the contents of a preelaborable subset.) I suppose 
you could send a request to reconsider this to Ada-Comment (but it would 
probably have to wait until the next Standard, whenever that is).

Someone asked about Ada.Tags. The entry for it says:

Ada.Tags -- 3.9; not categorized
  Package Tags has state, so it cannot be pure. That state is generally 
either
  set up at link-time (before elaboration) or during the elaboration of 
tagged
  types (that is, during the elaboration of other units). In either case, no
  complex state need be initialized at elaboration time. Thus, this package
  can be Preelaborated.

(The "state" that is talked about here is the table of internal tag <=> 
external tag mappings. Distributing that could be a significant overhead.) 
Making it Pure is not practical.

                                 Randy.

"Georg Bauhaus" <rm.dash-bauhaus@futureapps.de> wrote in message 
news:52a04caa$0$6636$9b4e6d93@newsspool2.arcor-online.net...
> On 05.12.13 04:58, Rod Kay wrote:
>> Hi all,
>>
>>     Would anyone know the reason for this ?
>
> Two possible reasons, guessing:
>
> 1) pragma Pure being >= Ada 95, and compatibility,
>
> 2) an implementation may choose to use pointers internally.
> 


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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-05 20:17   ` Randy Brukardt
@ 2013-12-06  3:03     ` Brad Moore
  2013-12-06  4:43       ` Rod Kay
  2013-12-06  4:36     ` Rod Kay
  1 sibling, 1 reply; 9+ messages in thread
From: Brad Moore @ 2013-12-06  3:03 UTC (permalink / raw)


On 05/12/2013 1:17 PM, Randy Brukardt wrote:
> We re-analyzed all of the existing packages for Ada 2005, and changed the
> categorization of some of them. The details can be found in AI95-0362-1
> (http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00362.txt).
>
> There is a listing of every predefined package in that AI. Here's the entry
> for Bounded strings:
>
> Ada.Strings.Bounded -- A.4.4; Preelaborate
>    This package contains no state, no dependence on non-pure units, no
>    other items that prevent the package from being pure, and does not declare
>    any types that would be a problem for Annex E, so it could be declared
> pure.
>    But it's large and complex, and many of the operations are not
> conceptually
>    pure (they do in-place updates), so no change is recommended.
>
> This admittedly does not seem very satisfying. We didn't redo this exercise
> for Ada 2012, the only change we made was to make Stream_IO preelaborated so
> that loggers and the like can be written.

Actually, this wasn't the only related change in Ada 2012. We also 
allowed Remote_Types packages and Remote_Call_Interface packages to 
depend on preelaborated packages, if that dependency is via a private 
with clause.

See

http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai05/ai05-0206-1.txt

This means that you can build abstractions that use Ada.Bounded_String 
(Or Ada.Tags for that matter), so long as they are not used in the 
visible part of a Remote_Types or Remote_Call_Interface package.

eg.

private with Ada.Strings.Bounded;

package RT is

    pragma Remote_Types;

    type W is private;

    procedure Set (Item : in out W;
                   Value : String);

    function Get (Item : W) return String;

private

    package My_String is new
      Ada.Strings.Bounded.Generic_Bounded_Length (Max => 100);

    type W is
       record
          D : My_String.Bounded_String;
       end record;

    function Get (Item : W) return String is (My_String.To_String (Item.D));
end RT;

package body RT is

    procedure Set
      (Item : in out W;
       Value : String) is
    begin
       My_String.Set_Bounded_String (Target => Item.D,
                                     Source => Value);
    end Set;

end RT;

Brad.

  (It's not practical to make the
> full Text_IO preelaborated [the obvious approach is not task-safe], and
> there was no agreement on the contents of a preelaborable subset.) I suppose
> you could send a request to reconsider this to Ada-Comment (but it would
> probably have to wait until the next Standard, whenever that is).
>
> Someone asked about Ada.Tags. The entry for it says:
>
> Ada.Tags -- 3.9; not categorized
>    Package Tags has state, so it cannot be pure. That state is generally
> either
>    set up at link-time (before elaboration) or during the elaboration of
> tagged
>    types (that is, during the elaboration of other units). In either case, no
>    complex state need be initialized at elaboration time. Thus, this package
>    can be Preelaborated.
>
> (The "state" that is talked about here is the table of internal tag <=>
> external tag mappings. Distributing that could be a significant overhead.)
> Making it Pure is not practical.
>
>                                   Randy.
>
> "Georg Bauhaus" <rm.dash-bauhaus@futureapps.de> wrote in message
> news:52a04caa$0$6636$9b4e6d93@newsspool2.arcor-online.net...
>> On 05.12.13 04:58, Rod Kay wrote:
>>> Hi all,
>>>
>>>      Would anyone know the reason for this ?
>>
>> Two possible reasons, guessing:
>>
>> 1) pragma Pure being >= Ada 95, and compatibility,
>>
>> 2) an implementation may choose to use pointers internally.
>>
>
>

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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-05  9:51 ` Georg Bauhaus
  2013-12-05 20:17   ` Randy Brukardt
@ 2013-12-06  4:28   ` Rod Kay
  1 sibling, 0 replies; 9+ messages in thread
From: Rod Kay @ 2013-12-06  4:28 UTC (permalink / raw)


On Thursday, 5 December 2013 20:51:40 UTC+11, Georg Bauhaus  wrote:
>
> Two possible reasons, guessing:
> 
> 1) pragma Pure being >= Ada 95, and compatibility,
> 
> 2) an implementation may choose to use pointers internally.

   Yes, both seem likely reasons, thanks.

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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-05 20:17   ` Randy Brukardt
  2013-12-06  3:03     ` Brad Moore
@ 2013-12-06  4:36     ` Rod Kay
  1 sibling, 0 replies; 9+ messages in thread
From: Rod Kay @ 2013-12-06  4:36 UTC (permalink / raw)


On Friday, 6 December 2013 07:17:05 UTC+11, Randy Brukardt  wrote:
> We re-analyzed all of the existing packages for Ada 2005, and changed the 
> categorization of some of them. The details can be found in AI95-0362-1 
>

   Thank you for the detailed explanation, Randy. I see the matter has been given a good deal of thought. I'd be happy to submit a request for further consideration in the next standard, if it seems a reasonable request.

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

* Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
  2013-12-06  3:03     ` Brad Moore
@ 2013-12-06  4:43       ` Rod Kay
  0 siblings, 0 replies; 9+ messages in thread
From: Rod Kay @ 2013-12-06  4:43 UTC (permalink / raw)


On Friday, 6 December 2013 14:03:09 UTC+11, Brad Moore  wrote:
> 
> Actually, this wasn't the only related change in Ada 2012. We also 
> allowed Remote_Types packages and Remote_Call_Interface packages to 
> depend on preelaborated packages, if that dependency is via a private 
> with clause.
> 

   Ah, that *is* nice. Will be quite useful, thank you. 

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

end of thread, other threads:[~2013-12-06  4:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-05  3:58 Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ? Rod Kay
2013-12-05  6:50 ` Shark8
2013-12-05  8:16   ` Rod Kay
2013-12-05  9:51 ` Georg Bauhaus
2013-12-05 20:17   ` Randy Brukardt
2013-12-06  3:03     ` Brad Moore
2013-12-06  4:43       ` Rod Kay
2013-12-06  4:36     ` Rod Kay
2013-12-06  4:28   ` Rod Kay

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