Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"I'm not afraid of dying, I just don't want to be there when it happens." -- Woody Allen


devel / comp.lang.ada / Re: Discriminant problem

SubjectAuthor
* Discriminant problemSimon Wright
+- Re: Discriminant problemSimon Wright
`* Re: Discriminant problemJeffrey R. Carter
 `* Re: Discriminant problemRandy Brukardt
  `- Re: Discriminant problemSimon Wright

1
Discriminant problem

<lytuj8dqya.fsf@pushface.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Discriminant problem
Date: Sun, 29 Aug 2021 19:51:57 +0100
Organization: Aioe.org NNTP Server
Message-ID: <lytuj8dqya.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="56256"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
Cancel-Lock: sha1:stjVDgJppL2Th4n5nlrH6Kvsk8s=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Sun, 29 Aug 2021 18:51 UTC

I have

Location_Step.Node_Test :=
(Node_Test => Get_Node_Type_Test (T.Node_Type_Part.all),
Name => Null_Unbounded_String);

where

type Location_Steps is record
...
Node_Test : Node_Test_Specification
:= (Node_Test => No_Node_Test,
Name => Null_Unbounded_String);
...
end record;

and

type Node_Test_Specification
(Node_Test : Node_Tests := No_Node_Test) is
record
Name : Unbounded_String;
case Node_Test is
...
end case;
end record;

Because of that function call in

Node_Test => Get_Node_Type_Test (T.Node_Type_Part.all)

the compiler says

value for discriminant "Node_Test" must be static
non-static function call (RM 4.9(6,18))

OK, I get that (tiresome though it is, and I'm amazed I've never come
across it before), but how to approach it? I seem to be OK with

case Get_Node_Type_Test (T.Node_Type_Part.all) is
when Text_Node_Test =>
Location_Step.Node_Test :=
(Node_Test => Text_Node_Test,
Name => Null_Unbounded_String);
when ...
end case;

but this seems very ugly.

I've only just noticed this: I'd been using -gnatX (so that I could use
'Image on records), which meant that the original code was OK (in the
sense that it didn't raise any problems), but of course it's not
portable even within the GNAT family. I think -gnat2020 might solve the
issue too, but there's a bit of a skew between CE 2021 and GCC 11.

Re: Discriminant problem

<lylf4je4es.fsf@pushface.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Discriminant problem
Date: Mon, 30 Aug 2021 09:13:31 +0100
Organization: Aioe.org NNTP Server
Message-ID: <lylf4je4es.fsf@pushface.org>
References: <lytuj8dqya.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="60201"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
Cancel-Lock: sha1:HUoBy8YujoQwhiqi60PNtFm7Tes=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Mon, 30 Aug 2021 08:13 UTC

Simon Wright <simon@pushface.org> writes:

> I've only just noticed this: I'd been using -gnatX (so that I could use
> 'Image on records), which meant that the original code was OK (in the
> sense that it didn't raise any problems), but of course it's not
> portable even within the GNAT family. I think -gnat2020 might solve the
> issue too, but there's a bit of a skew between CE 2021 and GCC 11.

The skew might well be about the semantics of -gnatX - not 100% sure.

The only way I can see that -gnat2020 would help would be if
Get_Node_Type_Test was a static expression function[1], but it's not
even an expression function! It could be, though since it involves tag
tests and can 'return' an exception this seems unlikely.

[1] http://www.ada-auth.org/standards/2xaarm/html/AA-4-9.html#p21.1

Re: Discriminant problem

<sgjkj4$kn4$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.not.acm.org (Jeffrey R. Carter)
Newsgroups: comp.lang.ada
Subject: Re: Discriminant problem
Date: Tue, 31 Aug 2021 00:03:16 +0200
Organization: Also freenews.netfront.net; news.tornevall.net;
news.eternal-september.org
Lines: 39
Message-ID: <sgjkj4$kn4$1@dont-email.me>
References: <lytuj8dqya.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 30 Aug 2021 22:03:17 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="170b88e280b372a24cf42b600488aae1";
logging-data="21220"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XcLNzxkzWEX+Nuo04lFBIFQkJXpy20uY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:tggAGy2mMLBVNBBh0H91XvohtXU=
In-Reply-To: <lytuj8dqya.fsf@pushface.org>
Content-Language: en-US
 by: Jeffrey R. Carter - Mon, 30 Aug 2021 22:03 UTC

On 8/29/21 8:51 PM, Simon Wright wrote:
>
> the compiler says
>
> value for discriminant "Node_Test" must be static
> non-static function call (RM 4.9(6,18))

This has always been the rule for aggregates.

> OK, I get that (tiresome though it is, and I'm amazed I've never come
> across it before), but how to approach it? I seem to be OK with

That is surprising.

> case Get_Node_Type_Test (T.Node_Type_Part.all) is
> when Text_Node_Test =>
> Location_Step.Node_Test :=
> (Node_Test => Text_Node_Test,
> Name => Null_Unbounded_String);
> when ...
> end case;
>
> but this seems very ugly.

Agreed. What I usually do is

declare
Result : Whatever (D => Non_Static_Value);
-- Discriminant of an object need not be static
begin
Result.F1 := ...;
...
Location_Step.Node_Test := Result;
end;

--
Jeff Carter
"You can never forget too much about C++."
115

Re: Discriminant problem

<sgk236$drg$1@franka.jacob-sparre.dk>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Discriminant problem
Date: Mon, 30 Aug 2021 20:53:41 -0500
Organization: JSA Research & Innovation
Lines: 19
Message-ID: <sgk236$drg$1@franka.jacob-sparre.dk>
References: <lytuj8dqya.fsf@pushface.org> <sgjkj4$kn4$1@dont-email.me>
Injection-Date: Tue, 31 Aug 2021 01:53:43 -0000 (UTC)
Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226";
logging-data="14192"; mail-complaints-to="news@jacob-sparre.dk"
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
 by: Randy Brukardt - Tue, 31 Aug 2021 01:53 UTC

"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message
news:sgjkj4$kn4$1@dont-email.me...
> On 8/29/21 8:51 PM, Simon Wright wrote:
>>
>> the compiler says
>>
>> value for discriminant "Node_Test" must be static
>> non-static function call (RM 4.9(6,18))
>
> This has always been the rule for aggregates.

But Ada 202x relaxes it slightly. If the expression has a static nominal
subtype, and every value in the subtype selects the same variant, then a
dynamic discriminant is allowed in a aggregate. I don't know if that is what
is happening here or not; this relaxation doesn't come up that often.

Randy.

Re: Discriminant problem

<lyilz9bk8k.fsf@pushface.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Discriminant problem
Date: Thu, 09 Sep 2021 20:51:39 +0100
Organization: Aioe.org NNTP Server
Message-ID: <lyilz9bk8k.fsf@pushface.org>
References: <lytuj8dqya.fsf@pushface.org> <sgjkj4$kn4$1@dont-email.me>
<sgk236$drg$1@franka.jacob-sparre.dk>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="4500"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:3D1MbS2J64xcvH63Pgtn/PFoS0I=
 by: Simon Wright - Thu, 9 Sep 2021 19:51 UTC

"Randy Brukardt" <randy@rrsoftware.com> writes:

> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message
> news:sgjkj4$kn4$1@dont-email.me...
>> On 8/29/21 8:51 PM, Simon Wright wrote:
>>>
>>> the compiler says
>>>
>>> value for discriminant "Node_Test" must be static
>>> non-static function call (RM 4.9(6,18))
>>
>> This has always been the rule for aggregates.
>
> But Ada 202x relaxes it slightly. If the expression has a static
> nominal subtype, and every value in the subtype selects the same
> variant, then a dynamic discriminant is allowed in a aggregate. I
> don't know if that is what is happening here or not; this relaxation
> doesn't come up that often.

That's exactly what's happening here.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor