comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Overriding puzzle
Date: Wed, 30 Dec 2015 17:10:27 -0600
Date: 2015-12-30T17:10:27-06:00	[thread overview]
Message-ID: <n61o94$nu8$1@loke.gir.dk> (raw)
In-Reply-To: 677d0956-63d3-4de8-a6e5-b79c52a1dc12@googlegroups.com

<marciant@earthlink.net> wrote in message 
news:677d0956-63d3-4de8-a6e5-b79c52a1dc12@googlegroups.com...
> On Wednesday, December 30, 2015 at 1:24:06 PM UTC-5, 
> gautier...@hotmail.com wrote:
>> No, the "A'Class(o)" also makes the difference when type Custom
>> is framed into a package:
>
...
> General note to self: tagged type operations that call other operations of 
> the type should always(?) convert the object to its 'class so as to cause 
> dispatching.  Not doing so is probably a defect!

Nooooo. Redispatching is best left for very limited circumstances. There's a 
reason that Ada makes you write it explicitly!

The model of Ada is that within a routine (including inherited routines) the 
object acts as if it had the named type. This makes it much easier to reason 
about the routine, as the behavior of all of the routines called is known.

When you redispatch, you no longer can reason in any useful way about the 
behavior of the call -- essentially you are depending on "magic" (and the 
competency of others) to get the right answer. In limited circumstances 
(like the OP), it works well, but for general programming, look out!

                                             Randy.


  reply	other threads:[~2015-12-30 23:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-30 14:49 Overriding puzzle gautier_niouzes
2015-12-30 15:10 ` Egil H H
2015-12-30 17:31   ` gautier_niouzes
2015-12-30 18:07   ` marciant
2015-12-30 18:24     ` gautier_niouzes
2015-12-30 21:40       ` marciant
2015-12-30 23:10         ` Randy Brukardt [this message]
2015-12-31  8:22           ` Niklas Holsti
2015-12-31  8:42             ` Dmitry A. Kazakov
2016-01-03  7:18             ` Randy Brukardt
2015-12-31 16:30           ` marciant
2015-12-30 23:13     ` Randy Brukardt
replies disabled

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