Ada Package Names and Methods

The question is out of curiosity here: is it possible to find the name of the method you are in? Something like this when I Magicshould output "foo.bar.foobar"without resorting to a string literal.

with ada.text_io;
package body foo.bar is 

   function foobar return boolean is 
   begin
     ada.text_io.put_line ("I am in :" & Magic);
     return true;
   end foobar;

end foo.bar;

I would suggest that the information is somewhere, as it is similarly displayed for stack traces, exceptions and profiling tools, etc., but I can not find it documented anywhere!

+3
source share
1 answer

As I am sure, you already know that Ada (unfortunately) does not support reflection.

However ... if you use GNAT and in the order of the utilities for the compiler, you can get this information from the GNAT.Source_Info package .

+3
source

All Articles