comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: deferred constants
Date: Wed, 7 Jul 2021 16:37:22 -0700 (PDT)	[thread overview]
Message-ID: <a6e2e912-8aa6-4ecf-9118-9dd29a967734n@googlegroups.com> (raw)
In-Reply-To: <4333d2e6-a4f6-46a8-a5df-78bb4e0d915en@googlegroups.com>

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 written in comments. (That I'm aware of.) 
> 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.RegExp? It has worked in our code for years. 
Regular expressions are for regular languages; it is very easy to violate that restriction with your incoming data.
Most of my professional career has been doing maintenance, and RegEx are *terrible* when it comes to maintainability, to the point that I actively avoid them and advise others to as well, even for things that conceptually *could* be done via RegEx (e.g. recognizing an Integer) in favor of actual parsing... 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 better way to add protection to this entity. It appears not when it is defined in 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 elaboration 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 the function result? 
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 internal objects. (eg Default_Map : Map renames Internal_Map_Generation(P1, P2); ... and then I can use "Default_Map" instead of calling the generation-function at each point and possibly messing things up should the parameters change.)

  reply	other threads:[~2021-07-07 23:37 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
2021-07-07 23:15   ` Matt Borchers
2021-07-07 23:37     ` Shark8 [this message]
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