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.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5b3c19b1631bb558 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-11-02 03:19:03 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!cyclone-sf.pbi.net!64.42.15.2!HSNX.atgi.net!telocity-west!TELOCITY!newsrump.sjc.telocity.net!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada References: <0O9M5.381209$i5.6373651@news1.frmt1.sfba.home.com> Subject: Re: Reflection (was: Re: The best thing/greatest feature summary) MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Message-ID: X-Trace: ODQgTm9BdXRoVXNlciBURUxPQ0lUWS1SRUFERVJTIDIxNi4yMjcuNDcuNKEgIFRodSwgMDIgTm92!IDIwMDAgMDM6MTc6MDggUFNU X-Abuse-Info: Please forward ALL headers when reporting abuse. X-Complaints-To: abuse@telocity.net NNTP-Posting-Date: Thu, 02 Nov 2000 03:17:08 PST Date: Thu, 2 Nov 2000 05:19:01 -0600 Xref: supernews.google.com comp.lang.ada:1714 Date: 2000-11-02T05:19:01-06:00 List-Id: Here is what might be considered an improvement on your package: with Ada.Tags; generic package Reflection is Unit_Name : constant String; private -- Reflection type T is abstract tagged null record; S : constant String := Ada.Tags.Expanded_Name (T'Tag); Unit_Name : constant String := S (1 .. S'Last - 2); end Reflection; package One is procedure P; procedure Q; end One; with Reflection, Ada.Text_Io; package body One is package Me is new Reflection; procedure P is begin Ada.Text_Io.Put_Line (Me.Unit_Name); end P; procedure Q is package Me is new Reflection; begin Ada.Text_Io.Put_Line (Me.Unit_Name); end Q; end One; with Reflection, One, Ada.Text_Io; procedure Test_Reflection is package Me is new Reflection; begin One.P; --> ONE.ME One.Q; --> ONE.Q.ME Ada.Text_Io.Put_Line (Me.Unit_Name); --> TEST_REFLECTION.ME end Test_Reflection; wrote in message news:0O9M5.381209$i5.6373651@news1.frmt1.sfba.home.com... > >Or does instantiating this package within a routine actually work? (I don't > >have an Ada compiler near me at the moment.) > Using Gnat 3.13p, > > with Ada.Tags; > generic package Reflection is > Unit_Name : constant String; > private -- Reflection > type T is abstract tagged null record; > Unit_Name : constant String := Ada.Tags.Expanded_Name (T'Tag); > end Reflection; > > package one is > procedure p; > procedure q; > end one; > > with reflection, > ada.text_io; > package body one is > package me is new reflection; > procedure p is > begin ada.text_io.put_line(me.unit_name);end p; > procedure q is > package myself is new reflection; > begin > ada.text_io.put_line(myself.unit_name); > end q; > end one; > > with reflection, > one, > ada.text_io; > procedure test is > package me is new reflection; > begin > one.p; --> ONE.ME.T > one.q; --> ONE.Q.MYSELF.T > ada.text_io.put_line(me.unit_name); --> TEST.ME.T > end test;