From: Shark8 <onewingedshark@gmail.com>
Subject: Re: deferred constants
Date: Wed, 7 Jul 2021 13:44:32 -0700 (PDT) [thread overview]
Message-ID: <2e09faca-1f9a-43d3-99cb-6ae0e27a741cn@googlegroups.com> (raw)
In-Reply-To: <5db8eeb4-f3fc-49a7-b588-6a4b25bdbafcn@googlegroups.com>
On Wednesday, July 7, 2021 at 1:31:34 PM UTC-6, Matt Borchers wrote:
> Is it possible to define a constant in a package body that has it's initialization deferred to elaboration?
>
> For example...
>
> with Gnat.RegExp;
> package body
> pat : constant Gnat.RegExp.RegExp;
> begin
> pat := Gnat.RegExp.compile( "..." );
> end;
>
> Obviously it is not strictly necessary to create 'pat' as a constant, but it is ideal to define symbols as precise as possible. Without it being a constant, the compiler will obviously not check to make sure someone has not inadvertently overwritten it.
>
> GNAT gives me the following errors:
> - constant declaration requires initialization expression
> - deferred constant is frozen before completion
>
> The first error message is not true, but comes from the fact that the second IS true. Is there a way to postpone the freezing of a symbol until after elaboration?
Use RENAMES?
pat : Gnat.RegExp.RegExp renames Gnat.RegExp.compile( "..." );
Other than this, I would advise not using RegEx.
next prev parent reply other threads:[~2021-07-07 20:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 19:31 deferred constants Matt Borchers
2021-07-07 20:40 ` Jeffrey R. Carter
2021-07-07 20:41 ` Stephen Leake
2021-07-07 20:44 ` Shark8 [this message]
2021-07-07 23:15 ` Matt Borchers
2021-07-07 23:37 ` Shark8
2022-07-06 16:18 ` RegEx / rename of a function result Thomas
2022-07-06 17:56 ` J-P. Rosen
2022-07-06 19:11 ` Jeffrey R.Carter
2022-07-07 5:51 ` RegEx / rename of a function resultRig J-P. Rosen
2022-07-11 17:49 ` RegEx / rename of a function result Thomas
2022-07-12 5:13 ` J-P. Rosen
2022-07-12 14:45 ` G.B.
2022-07-07 0:44 ` Randy Brukardt
2022-07-11 17:45 ` Thomas
2022-07-12 6:54 ` Randy Brukardt
2021-07-08 1:21 ` deferred constants Stephen Leake
2021-07-08 14:18 ` Maxim Reznik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox