From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Interesting article on ARG work
Date: Thu, 5 Apr 2018 17:18:57 -0500
Date: 2018-04-05T17:18:57-05:00 [thread overview]
Message-ID: <pa67ci$t34$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: pa4ip3$1ton$1@gioia.aioe.org
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:pa4ip3$1ton$1@gioia.aioe.org...
> On 05/04/2018 00:30, Randy Brukardt wrote:
>
>> There is a much more general proposal for Ada 2020 called "ghost code" -
>> a
>> silly name for code and declarations intended only to be used by
>> assertions.
>> (The idea being that if it is marked and enforced as such, it can be
>> removed
>> when the Assertion_Policy is Ignore.)
>>
>> Using that (which may or may not make it into Ada 2020 -- we haven't yet
>> discussed it at a meeting), one could use a ghost function for this
>> purpose:
>>
>> function My_Assertion (...) return Boolean is
>> (if Condition then raise Assertion_Error with Message else
>> True)
>> with Ghost;
>>
>> pragma Assert (My_Assertion (...));
>>
>> (Note: The "..." here is any objects that Condition needs to be
>> evaluated.)
>
> Assertion code is quite useless from my point of view, but what about
> debugging code? It is quite tedious to comment it in and out all the time
> (and with/use clauses required for it).
My assumption has always been that Ghost code could be used for that as
well, but since it's more of an idea than a proposal, it's hard to say
anything definitive.
If you used Janus/Ada, you'd have a built-in solution for that (sadly,
incompatible with Ada 2020): the @ conditional compilation marker. It is
interpreted as either "--" or " " depending on a compilation flag, so it can
easily add or remove anything. We originally invented it to deal with
debugging/assertion code in the Janus/Ada compiler; probably about 25% of
the code in Janus/Ada is marked that way. Since it is lexical, it can
comment out anything, including declarations, pragmas, and with clauses.
In programs intended to be portable, I just use static Boolean flags for
debugging code. Any compiler with decent dead code elimination (which would
be about all of them) will get rid of most/all of the code that way. But
that doesn't work on pragmas, context clauses, or declarations, so it isn't
quite as through as @. (With Janus/Ada, which does dead subprogram
elimination during binding, including for tagged type primitives, the
difference isn't that substantial unless large data declarations are
involved.)
Randy.
next prev parent reply other threads:[~2018-04-05 22:18 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-02 3:32 Interesting article on ARG work Randy Brukardt
2018-04-02 14:49 ` Dan'l Miller
2018-04-03 16:34 ` Bojan Bozovic
2018-04-03 22:33 ` Randy Brukardt
2018-04-04 2:12 ` Bojan Bozovic
2018-04-04 15:05 ` Dan'l Miller
2018-04-04 15:30 ` gerdien.de.kruyf
2018-04-04 16:09 ` Dan'l Miller
2018-04-04 22:30 ` Randy Brukardt
2018-04-04 22:43 ` Paul Rubin
2018-04-05 0:44 ` Mehdi Saada
2018-04-05 21:23 ` Randy Brukardt
2018-04-05 2:05 ` Bojan Bozovic
2018-04-05 22:12 ` Randy Brukardt
2018-04-06 13:35 ` Bojan Bozovic
2018-04-07 2:01 ` Randy Brukardt
2018-04-05 7:21 ` Dmitry A. Kazakov
2018-04-05 22:18 ` Randy Brukardt [this message]
2018-04-06 7:30 ` Dmitry A. Kazakov
2018-04-07 2:25 ` Randy Brukardt
2018-04-07 10:11 ` Dmitry A. Kazakov
2018-04-07 15:27 ` Dan'l Miller
2018-04-07 15:59 ` Dmitry A. Kazakov
2018-04-08 0:14 ` Dan'l Miller
2018-04-08 7:46 ` Dmitry A. Kazakov
2018-04-08 19:48 ` Dan'l Miller
2018-04-08 20:09 ` Dmitry A. Kazakov
2018-04-09 3:50 ` Dan'l Miller
2018-04-09 6:40 ` Jan de Kruyf
2018-04-09 7:43 ` Dmitry A. Kazakov
2018-04-09 13:40 ` Dan'l Miller
2018-04-09 14:13 ` Dmitry A. Kazakov
2018-04-09 14:36 ` Dan'l Miller
2018-04-09 14:44 ` Dmitry A. Kazakov
2018-04-09 15:03 ` Dan'l Miller
2018-04-09 16:12 ` Niklas Holsti
2018-04-09 16:30 ` Dmitry A. Kazakov
2018-04-09 16:45 ` Niklas Holsti
2018-04-09 17:33 ` Dan'l Miller
2018-04-09 19:47 ` Dmitry A. Kazakov
2018-04-09 20:24 ` Randy Brukardt
2018-04-10 8:17 ` Dmitry A. Kazakov
2018-04-09 18:08 ` Dan'l Miller
2018-04-09 21:17 ` Niklas Holsti
2018-04-09 22:09 ` Dan'l Miller
2018-04-10 19:23 ` Niklas Holsti
2018-04-10 19:46 ` Dan'l Miller
2018-04-15 7:50 ` Niklas Holsti
2018-04-15 13:31 ` Dan'l Miller
2018-04-15 18:37 ` Niklas Holsti
2018-04-09 20:14 ` Randy Brukardt
2018-04-06 23:49 ` Dan'l Miller
2018-04-12 10:21 ` Marius Amado-Alves
2018-04-15 13:07 ` Ada conditional compilation and program variants Niklas Holsti
2018-05-07 8:41 ` Jacob Sparre Andersen
2018-04-06 13:35 ` Interesting article on ARG work Marius Amado-Alves
2018-04-07 2:15 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox