From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:ac8:525a:: with SMTP id y26mr2527061qtn.254.1625686293714; Wed, 07 Jul 2021 12:31:33 -0700 (PDT) X-Received: by 2002:a25:ac9a:: with SMTP id x26mr35831900ybi.161.1625686293505; Wed, 07 Jul 2021 12:31:33 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 7 Jul 2021 12:31:33 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=209.104.249.61; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA- NNTP-Posting-Host: 209.104.249.61 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5db8eeb4-f3fc-49a7-b588-6a4b25bdbafcn@googlegroups.com> Subject: deferred constants From: Matt Borchers Injection-Date: Wed, 07 Jul 2021 19:31:33 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:62340 List-Id: 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?