comp.lang.ada
 help / color / mirror / Atom feed
From: Brad Moore <brad.moore@shaw.ca>
Subject: Re: Reason for 'Ada.Strings.Bounded' not being declared 'pragma Pure' ?
Date: Thu, 05 Dec 2013 20:03:09 -0700
Date: 2013-12-05T20:03:09-07:00	[thread overview]
Message-ID: <t7bou.516770$VX2.218363@fx31.iad> (raw)
In-Reply-To: <l7qn02$v8t$1@loke.gir.dk>

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.
>>
>
>

  reply	other threads:[~2013-12-06  3:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2013-12-06  4:43       ` Rod Kay
2013-12-06  4:36     ` Rod Kay
2013-12-06  4:28   ` Rod Kay
replies disabled

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