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.5 required=3.0 tests=BAYES_05,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:6214:1921:: with SMTP id es1mr26913807qvb.61.1625701042666; Wed, 07 Jul 2021 16:37:22 -0700 (PDT) X-Received: by 2002:a25:6b0c:: with SMTP id g12mr30726839ybc.303.1625701042480; Wed, 07 Jul 2021 16:37:22 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!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 16:37:22 -0700 (PDT) In-Reply-To: <4333d2e6-a4f6-46a8-a5df-78bb4e0d915en@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: <5db8eeb4-f3fc-49a7-b588-6a4b25bdbafcn@googlegroups.com> <2e09faca-1f9a-43d3-99cb-6ae0e27a741cn@googlegroups.com> <4333d2e6-a4f6-46a8-a5df-78bb4e0d915en@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: deferred constants From: Shark8 Injection-Date: Wed, 07 Jul 2021 23:37:22 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:62347 List-Id: On Wednesday, July 7, 2021 at 5:15:43 PM UTC-6, Matt Borchers wrote: > Of course comments help, but the compiler does not enforce what is writte= n in comments. (That I'm aware of.)=20 > The fact that the example uses RegExp doesn't matter, it was just code I = ran across and the example could be anything. BTW, what's wrong with Gnat.R= egExp? It has worked in our code for years.=20 Regular expressions are for regular languages; it is very easy to violate t= hat restriction with your incoming data. Most of my professional career has been doing maintenance, and RegEx are *t= errible* when it comes to maintainability, to the point that I actively avo= id them and advise others to as well, even for things that conceptually *co= uld* be done via RegEx (e.g. recognizing an Integer) in favor of actual par= sing... or if you need pattern-matching, something more robust like SNOBOL. > I was looking at old code and began wondering if there was a new or bette= r way to add protection to this entity. It appears not when it is defined i= n the elaboration block. > I suppose I could just move the call to 'compile' out of the begin block = of the package as people have suggested. At what point do constants defined= by a function call get elaborated? Before or after the elaboration block? = Might I then potentially encounter a elaboration race condition? This is where the categorization pragmas/aspects come in: if a package that= you are depending on are PURE or PREELABORATE then there can be no elabora= tion error. If the type you are relying on is PREELABORABLE_INITIALIZATION,= then there can be no elaboration error. All other conditions are a solid *= maybe* on having an elaboration error. > The RENAME is interesting as I have not seen that before. Is it a rename = of the function call (invokes the function upon reference) or a rename of t= he function result?=20 That form of RENAMES is the function result. I've found it an excellent alternative to CONSTANT, as it signals my intent= to have an alias for some result inside DECLARE blocks and certain interna= l objects. (eg Default_Map : Map renames Internal_Map_Generation(P1, P2); .= .. and then I can use "Default_Map" instead of calling the generation-funct= ion at each point and possibly messing things up should the parameters chan= ge.)