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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,335027991b3a97ec X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Debug code Date: 1996/03/18 Message-ID: #1/1 X-Deja-AN: 143785119 references: <1996Mar14.223326.13730@nosc.mil> <4iborm$a27@dfw.dfw.net> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-03-18T00:00:00+00:00 List-Id: Dave Weller said "All in all, I've found this feature to be enormously powerful. I only regret that it couldn't make it into the standard (yet :-)" talking of the GNAT pragma Assert. Actually thre are good reasons why this is not in the standard. It is surprisingly quite difficult to define exactly from a semantic point of view (the issue is that if it really is equivalent to the if from a formal semantic point of view, then the compiler could draw conclusions from its existence and affect code outside the Assert which you don't want. Avoiding such effects is (a) difficult to formally define and (b) in some environments difficult to implement. Still it seems likely that other Ada 95 compilers will simply copy this useful pragma, so the de facto effect of standardization may be achieved anyway! Another GNAT pragma is pragma Debug. pragma Debug (procedure call); e.g. pragma Debug (Put_Line ("got to point 32")); This can occur either in a declarative part or a statement part, and like pragma Assert is controlled by the -gnata switch of GNAT. If -gnata is off, the pragma is ignored, if -gnata is set, it is equivalent to the procedure call (the ability to get print statements into declarative parts is particularly handy). Note to the formalists: this pragma is a bit dubious, since semantically the argument is not an expression, but it is syntactically an expression, so strictly it is an acceptable, though odd, addition. This oddness may however introduce implementatoin difficulties, so I am not quite as sure this pragma will be copied (of course other implementations should then ignore it at least). By the way, although both pragma Assert and Debug feel like statements, syntatically they are not, so you cannot write else pragma Assert ( ....); end if; you need a null statement: else pragma Assert ( ...); null; end if; Incidentally the GNAT source is full of pragma Assert statements, which is why the current front end is very slow compared to what it will be in a future release.