comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Runtime type selection
Date: Tue, 13 Oct 2009 12:17:51 +0200
Date: 2009-10-13T12:17:51+02:00	[thread overview]
Message-ID: <13962r9wa97u9$.6gtel38cl93s.dlg@40tude.net> (raw)
In-Reply-To: alpine.LNX.2.00.0910131044380.29923@Bluewhite64.example.net

On Tue, 13 Oct 2009 10:45:41 +0000, Colin Paul Gloster wrote:

> On Sun, 11 Oct 2009, Dmitry A. Kazakov wrote:
> 
>|----------------------------------------------------------------------------|
>|"                                                                           |
>|On Sun, 11 Oct 2009 09:41:54 -0700 (PDT), xorque wrote:                     |
>|                                                                            |
>|> I'd like to develop a program that processes a graph. The contents of     |
>|> the graph are a random selection of objects of different types (all       |
>|> elements may be of the same type or may all be different - assuming       |
>|> there are enough types defined). By 'type' in this case, I am             |
>|> referring to Ada types.                                                   |
>|>                                                                           |
>|> The basic problem is that I want to create an object of a type picked     |
>|> at random, at runtime. I'm not entirely sure what my options are here.    |
>|                                                                            |
>|The problem is that graph nodes have nothing in common. Thus there is       |
>|nothing except for the graph traversal operations you could implement on    |
>|the graph as a whole.                                                       |
>|                                                                            |
>|[..]"                                                                       |
>|----------------------------------------------------------------------------|
> 
> You made it sound as if a Visitor Pattern might work.

In which case nodes would be descendants of some common root with the
visitor's accept operation. A common interface would change everything,
however. 

Interesting is that Ada's pool-specific pointers (to class-wide targets)
are a kind of doubly dispatching (pool class x type class), which in the
end allows visitor-like implementations without any common root.

There is another case of hidden double dispatch in Ada. It is stream
attributes T'Class'Input and T'Class'Output (stream class x type class).

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



  reply	other threads:[~2009-10-13 10:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-11 16:41 Runtime type selection xorque
2009-10-11 17:02 ` Niklas Holsti
2009-10-11 17:15   ` xorque
2009-10-11 19:54     ` Niklas Holsti
2009-10-12  9:26       ` Georg Bauhaus
2009-10-12 12:02         ` xorque
2009-10-12 23:42       ` Randy Brukardt
2009-10-13  6:50         ` Niklas Holsti
2009-10-13  0:59       ` Adam Beneschan
2009-10-13  7:01         ` Niklas Holsti
2009-10-11 17:15 ` mockturtle
2009-10-11 20:06 ` Dmitry A. Kazakov
2009-10-13 10:45   ` Colin Paul Gloster
2009-10-13 10:17     ` Dmitry A. Kazakov [this message]
2009-10-13 15:11 ` xorque
2009-10-13 15:50   ` Dmitry A. Kazakov
2009-10-13 16:02     ` xorque
replies disabled

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