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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d6413a22d4aaecda X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Program identification Date: 1996/09/03 Message-ID: <01bb9986$a6da1c80$438371a5@dhoossr.iquest.com>#1/1 X-Deja-AN: 178159962 distribution: world references: content-type: text/plain; charset=ISO-8859-1 organization: DBH Enterprises, Inc. mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-09-03T00:00:00+00:00 List-Id: Chris Sparks wrote in article ... > Does anyone know of a way to determine the program name within a program > without explictly making a constant for it. If there isn't a way then > maybe a new attribute should be made for the next version of Ada, namely: > > P'Identity which returns a string, P is a program unit > > I am using this information as part of an exception reporter system. > > BTW these would be helpful too: > > P'Location which returns a string, P is a program unit and the string would > contain the current line number in the source code, or maybe even the previous > line number (for exception processing). > > Any thoughts? > The gnat compiler has an assert mechanism which will identify source file name and line numbers. It is used in the compiler code itself to do just what you describe. It seems to me that you don't need to know the program unit name if you know the source code location -- but I haven't seen how, or thought through whether there is any way to identify the location of the instantiation, if the assertion fails in a generic unit's code. Incidentally, you need to turn on a compiler switch to activate the assertion mechanism. -- David C. Hoos, Sr., http://www.dbhwww.com http://www.ada95.com