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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!news.stack.nl!cs.uu.nl!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Tell whether a primitive subprogram was overridden Date: Tue, 19 Aug 2014 10:50:21 +0100 Organization: A noiseless patient Spider Message-ID: References: <0b8124b3-5d31-4c2b-a27e-64795625c7f0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="b814ca014269fd1fa21bc4c05b94dd9e"; logging-data="6377"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wE+azjf90aF+L2mNN8fcH8VQBsXzs6+A=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:XvFwBDAWtUuYLS9TniJ23HNYpQM= sha1:nMR9NYRNOPMqzlv0OvQVVp9ekTw= Xref: number.nntp.dca.giganews.com comp.lang.ada:188556 Date: 2014-08-19T10:50:21+01:00 List-Id: Victor Porton writes: > 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. > > No, I won't add this obscure function F_Does_Something_Useful only to > increase the speed for a tiny bit. Then you shouldn't be worrying about efficiency in the first place! (later on, maybe ...)