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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx01.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:34.0) Gecko/20100101 Thunderbird/34.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Tell whether a primitive subprogram was overridden References: <0b8124b3-5d31-4c2b-a27e-64795625c7f0@googlegroups.com> In-Reply-To: <0b8124b3-5d31-4c2b-a27e-64795625c7f0@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Tue, 19 Aug 2014 01:29:56 UTC Organization: TeraNews.com Date: Mon, 18 Aug 2014 19:29:48 -0600 X-Received-Bytes: 1925 X-Received-Body-CRC: 1321180014 Xref: news.eternal-september.org comp.lang.ada:21821 Date: 2014-08-18T19:29:48-06:00 List-Id: On 18-Aug-14 17:52, Adam Beneschan wrote: > 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 > You *MIGHT* be able to do it w/ LISP; the homoiconic nature and first-class functions should combine quite well with the OOP framework to allow such a query.