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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,9cbcb326ab4299b1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!news2.euro.net!newsfeed.freenet.ag!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Package name as string Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <9IK6p.32469$2t5.26524@newsfe24.ams2> Date: Wed, 16 Feb 2011 09:52:43 +0100 Message-ID: NNTP-Posting-Date: 16 Feb 2011 09:52:43 CET NNTP-Posting-Host: 516ab259.newsspool3.arcor-online.net X-Trace: DXC=d7SYX9RI[Qa[F<50eo:0knMcF=Q^Z^V3h4Fo<]lROoRa8kF On Wed, 16 Feb 2011 08:06:45 +0100, Per Sandberg wrote: > Simplest way with GNAT is: > > with GNAT.Source_Info; > package body blaa is > package_name : constant String := GNAT.Source_Info.Enclosing_Entity; > ... > ... > end blaa; A possible GNAT-independent implementation: with Ada.Tags; function Name return String is type Dummy is tagged limited null record; Result : String := Ada.Tags.Expanded_Name (Dummy'Tag); begin return Result (Result'First..Result'Last - 11); end Name; To be cut and pasted into each body where it has to be used. [ Of course with generic instances the question becomes ambiguous. ] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de