comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Tell whether a primitive subprogram was overridden
Date: Tue, 19 Aug 2014 09:31:43 +0200
Date: 2014-08-19T09:31:43+02:00	[thread overview]
Message-ID: <1nlld44wut4kf.1l1mtjf7durro.dlg@40tude.net> (raw)
In-Reply-To: lsu2v4$hn0$1@speranza.aioe.org

On Tue, 19 Aug 2014 02:41:24 +0300, 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)?

It is always overridden even if inherited. Purely formally, since the type
is different, e.g. S derived from T, then it cannot be the same subprogram.
[Technically it can have some additional trampoline code as well.]

> I would like this check for efficiency reasons, not to pass it to a callback 
> if the default "null" operation was not overridden.

You mean that a check would be more efficient than a dispatching call? I
don't think there would be much difference, except the case when the
subprogram has a long list of additional arguments or computed arguments.
That is usually the case when doing tracing stuff. In that case you could
think of some lazy parameter evaluation schema or upfront checks as Adam
suggested.

You could also split the base type into two or more types adding the
primitive operations up the derivation tree. At the call point you could
check if the descendant is in the subclass that has the operation and call
only if it is. But I think this, apart from being extremely ugly, might be
in fact slower than a honest dispatching call.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2014-08-19  7:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18 23:41 Tell whether a primitive subprogram was overridden Victor Porton
2014-08-18 23:52 ` Adam Beneschan
2014-08-18 23:57   ` Victor Porton
2014-08-19  9:50     ` Simon Wright
2014-08-19  1:29   ` Shark8
2014-08-19  7:31 ` Dmitry A. Kazakov [this message]
2014-08-19 13:45   ` Victor Porton
2014-08-19 13:57     ` Dmitry A. Kazakov
2014-08-19 15:54       ` Victor Porton
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox