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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.207.164 with SMTP id n24mr18488772yho.5.1408405969587; Mon, 18 Aug 2014 16:52:49 -0700 (PDT) X-Received: by 10.50.41.103 with SMTP id e7mr59661igl.8.1408405969492; Mon, 18 Aug 2014 16:52:49 -0700 (PDT) Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!i13no993282qae.1!news-out.google.com!aw9ni1931igc.0!nntp.google.com!r2no2526968igi.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 18 Aug 2014 16:52:48 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0b8124b3-5d31-4c2b-a27e-64795625c7f0@googlegroups.com> Subject: Re: Tell whether a primitive subprogram was overridden From: Adam Beneschan Injection-Date: Mon, 18 Aug 2014 23:52:49 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.dca.giganews.com comp.lang.ada:188545 Date: 2014-08-18T16:52:48-07:00 List-Id: On Monday, August 18, 2014 4:41:24 PM UTC-7, Victor Porton wrote: > Is it possible to determine whether for a given object of type T'Class a > primitive subprogram F was overridden (not the same as for type T)? > > I would like this check for efficiency reasons, not to pass it to a callback > if the default "null" operation was not overridden. No, Ada doesn't provide a mechanism for this. I don't know of a language that does, although in some languages you might be able to use "reflection" to squeeze the information out, but with some difficulty. The best solution that I can think of is to add a function to T: function F_Does_Something_Useful (Obj : T) return boolean; This would be False for T, but for any derived type where you override F, you'd also override this function to make it return True. -- Adam