From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!news.etla.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Interesting article on ARG work Date: Fri, 6 Apr 2018 21:25:29 -0500 Organization: JSA Research & Innovation Message-ID: References: <1b44444f-c1b3-414e-84fb-8798961487c3@googlegroups.com> <62ee0aac-49da-4925-b9aa-a16695b3fc45@googlegroups.com> <9879872e-c18a-4667-afe5-41ce0f54559f@googlegroups.com> Injection-Date: Sat, 7 Apr 2018 02:25:30 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="594"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:51370 Date: 2018-04-06T21:25:29-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:pa77nc$1pu1$1@gioia.aioe.org... > On 06/04/2018 00:18, Randy Brukardt wrote: ... >> 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.) > > Yes, it is frequently "with Ada.Text_IO" or some internal package like > Dump_Pool etc. One could easily imagine record components provided for > debugging purpose and attributes selected differently, e.g. X'Storage_Pool > etc. With Janus/Ada's trimming technology, the only part of a package that has to appear in the final program is the elaboration code. So for a package like Text_IO, 98% of it would get discarded if not used. That only fails if there is a large data area (data isn't trimmed) and especially if there is a significant cost to initialize that data. Still, there are cases where the lexical switching works better; we use it to suppress (or not) other checks, remove the interactive debugging features, and the like. (However, in practice, the last couple of Janus/Ada versions were delivered with all of that code intact; the code memory use of the compiler is almost irrelevant on modern machines, and it means that failures are much more likely to be predictable.) > Another "requirement" is integration into IDE. It should be easy for the > IDE to hide all this code when debugging is inactive and colorize it > differently when active. That sounds like a good idea. > Janus/Ada solution looks better than pragma. And it could be extended to > provide multiple sections of debugging code which could be activated and > deactivated independently. The biggest problem with a lexical solution (and the reason that Ichbiah hated them) is that it's trivial to accidentally create a program that is only legal in one mode or the other. One has to continually compile everything in each possible mode to ensure that there aren't silly syntax errors involved. A common mistake that I make all of the time is: if Foo then Bar; else @ Internal_Error; end if; With the conditional compilation off, the "Internal_Error" is commented out and the above isn't syntactically legal. Ichbiah wanted to eliminate that from Ada, so there's no Include (a common feature of other languages back in the day, and heavily used in the very early versions of Janus/Ada, long gone now), no preprocessor, and so on -- everything is handled within the usual syntax of the language. Which doesn't always work that well... Randy.