Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Keep the number of passes in a compiler to a minimum. -- D. Gries


devel / comp.lang.ada / Formal Package Compiler Differences

SubjectAuthor
* Formal Package Compiler DifferencesJeffrey R.Carter
`- Re: Formal Package Compiler DifferencesJeffrey R.Carter

1
Formal Package Compiler Differences

<u8s6vp$bgn$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9842&group=comp.lang.ada#9842

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Formal Package Compiler Differences
Date: Fri, 14 Jul 2023 21:17:13 +0200
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <u8s6vp$bgn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 14 Jul 2023 19:17:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4fe757db35c7f68d0f3d5b21fae86dc6";
logging-data="11799"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Mrxl7PyVF6UXyv84PvOtlAFvRM4Gml/A="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:iq/sgLZBBnYIiEleFH0Fdz25ay0=
Content-Language: en-US
 by: Jeffrey R.Carter - Fri, 14 Jul 2023 19:17 UTC

I have a generic pkg;

with Ada.Containers.Vectors;

generic -- Vector_Conversions
type Index is range <>;
type Element is private;
type Fixed is array (Index range <>) of Element;

with function "=" (Left : in Element; Right : in Element) return Boolean
is <>;

with package Unbounded is new Ada.Containers.Vectors
(Index_Type => Index, Element_Type => Element);
package Vector_Conversions is
-- Empty
end Vector_Conversions;

and an instantiation of

with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Vector_Conversions;

procedure Instance_Test is
use Ada.Strings.Unbounded;

package String_Lists is new Ada.Containers.Vectors
(Index_Type => Positive, Element_Type => Unbounded_String);

type String_List is array (Positive range <>) of Unbounded_String;

package Conversions is new Vector_Conversions
(Index => Positive,
Element => Unbounded_String,
Fixed => String_List,
Unbounded => String_Lists);
begin -- Instance_Test
null;
end Instance_Test;

Compiler G compiles this and it works fine.

Compiler O fails to compile the instantiation with the error msg "The subprogram
actuals for the formal package and actual package must statically denote the
same entity", pointing to the Unbounded parameter association and referencing
ARM 12.7(8). If I add an explicit "=" with "is <>" to Vector_Conversions, then
compiler O compiles it and it works fine.

Possibly one of the compilers has an error, but possibly they're both correct,
and I'm wondering if it's possible to tell which is the case.

(If anyone is interested, the actual generic pkg where I encountered this is
PragmARC.Conversions.Vectors from the PragmAda Reusable Components
[https://github.com/jrcarter/PragmARC]), and I will supply the actual code that
instantiates it on demand. What I've presented is a first attempt at a minimal
reproducer.)

--
Jeff Carter
"Make sure your code 'does nothing' gracefully."
Elements of Programming Style
196

Re: Formal Package Compiler Differences

<u8s7j6$bh0$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9843&group=comp.lang.ada#9843

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Formal Package Compiler Differences
Date: Fri, 14 Jul 2023 21:27:34 +0200
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <u8s7j6$bh0$1@dont-email.me>
References: <u8s6vp$bgn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 14 Jul 2023 19:27:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4fe757db35c7f68d0f3d5b21fae86dc6";
logging-data="11808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PIVRgBL8OwylqXz77c1C47j252IcHirI="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:HNfKvDWLxPmNnrsuZ8NvA3MBjRo=
Content-Language: en-US
In-Reply-To: <u8s6vp$bgn$1@dont-email.me>
 by: Jeffrey R.Carter - Fri, 14 Jul 2023 19:27 UTC

On 2023-07-14 21:17, Jeffrey R.Carter wrote:
> I have a generic pkg;
>
> with Ada.Containers.Vectors;
>
> generic -- Vector_Conversions
>    type Index is range <>;
>    type Element is private;
>    type Fixed is array (Index range <>) of Element;
>
>    with function "=" (Left : in Element; Right : in Element) return Boolean
>    is <>;

Oops! This "=" should be removed to get the behavior described.

>
>    with package Unbounded is new Ada.Containers.Vectors
>       (Index_Type => Index, Element_Type => Element);
> package Vector_Conversions is
>    -- Empty
> end Vector_Conversions;
>
> and an instantiation of
>
> with Ada.Containers.Vectors;
> with Ada.Strings.Unbounded;
> with Vector_Conversions;
>
> procedure Instance_Test is
>    use Ada.Strings.Unbounded;
>
>    package String_Lists is new Ada.Containers.Vectors
>       (Index_Type => Positive, Element_Type => Unbounded_String);
>
>    type String_List is array (Positive range <>) of Unbounded_String;
>
>    package Conversions is new Vector_Conversions
>       (Index     => Positive,
>        Element   => Unbounded_String,
>        Fixed     => String_List,
>        Unbounded => String_Lists);
> begin -- Instance_Test
>    null;
> end Instance_Test;
>
> Compiler G compiles this and it works fine.
>
> Compiler O fails to compile the instantiation with the error msg "The subprogram
> actuals for the formal package and actual package must statically denote the
> same entity", pointing to the Unbounded parameter association and referencing
> ARM 12.7(8). If I add an explicit "=" with "is <>" to Vector_Conversions, then
> compiler O compiles it and it works fine.
>
> Possibly one of the compilers has an error, but possibly they're both correct,
> and I'm wondering if it's possible to tell which is the case.
>
> (If anyone is interested, the actual generic pkg where I encountered this is
> PragmARC.Conversions.Vectors from the PragmAda Reusable Components
> [https://github.com/jrcarter/PragmARC]), and I will supply the actual code that
> instantiates it on demand. What I've presented is a first attempt at a minimal
> reproducer.)
>

--
Jeff Carter
"Make sure your code 'does nothing' gracefully."
Elements of Programming Style
196

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor