comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Debug code
Date: 1996/03/18
Date: 1996-03-18T00:00:00+00:00	[thread overview]
Message-ID: <dewar.827152644@schonberg> (raw)
In-Reply-To: 4iborm$a27@dfw.dfw.net

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.





  reply	other threads:[~1996-03-18  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1996Mar14.223326.13730@nosc.mil>
1996-03-15  0:00 ` Debug code Bob Kitzberger
1996-03-15  0:00 ` David Weller
1996-03-18  0:00   ` Robert Dewar [this message]
1996-03-18  0:00     ` Robert A Duff
     [not found]       ` <dewar.827166947@schonberg>
1996-03-19  0:00         ` Norman H. Cohen
1996-03-25  0:00 Debug Code Sundog Software
1996-03-25  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-02-27  0:00 Jerry Blasdel
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox