comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: Multiple dispatch
Date: Wed, 15 Jun 2011 10:30:43 +0000 (UTC)
Date: 2011-06-15T10:30:43+00:00	[thread overview]
Message-ID: <slrnivh2ej.i18.lithiumcat@sigil.instinctive.eu> (raw)
In-Reply-To: 11peqoimzzkd9$.foyzy9udb4dt$.dlg@40tude.net

Hello,

On 2011-06-11, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
> On Sat, 11 Jun 2011 15:19:00 +0200, Yannick Duchêne (Hibou57) wrote:
>
>> Le Sat, 11 Jun 2011 13:52:05 +0200, Dmitry A. Kazakov  
>> <mailbox@dmitry-kazakov.de> a écrit:
>>> Yes, that looks like the usual pattern for protocols and similar stuff,
>>> when objects do not depend on the container.
>> What kind of dependencies do you have in mind ? Object existence depending  
>> on the container ? Or object's properties depending on the container ?
>
> Any dependencies (correlations). Imagine the dispatching table. It is a 2D
> matrix for double dispatch. In full dispatch the table is irregular, i.e.
> there is no preferred way to index this matrix either by columns or by
> rows.

I remember having faced that kind of issues with C through dynamic
linker introspection : there is a function that returns a function
pointer corresponding to the given symbol name. I crafted the symbol
name using an operation like
"dispatch_prefix_" & First_Tag & "_" & Second_Tag

This makes the dispatch table completely isotropic and allows to
implement any element of the matrix in any compilation unit (as long as
it is linked (statically or dynamically) to the final binary). I found
this feature very nice when the "glue" between the row type and the
column type does not obviously belong to either type (in the original
example, that would be a very special representation of a given general
data type in a given general container).

I guess the introspection of object files is too low level for Ada, and
even importing libdl from C wouldn't be of much use because of the
name-mangling performed by Ada compiler (or you have to use C symbol
names and give up namespaces, case-insensitivity and other cool Ada
features).

I know other high-level languages do have introspection mechanisms, but
I haven't seen anything like that in Ada. Have I missed them?


Natasha



  parent reply	other threads:[~2011-06-15 10:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-11 10:13 Multiple dispatch Yannick Duchêne (Hibou57)
2011-06-11 11:52 ` Dmitry A. Kazakov
2011-06-11 13:19   ` Yannick Duchêne (Hibou57)
2011-06-11 13:57     ` Dmitry A. Kazakov
2011-06-11 18:42       ` Emmanuel Briot
2011-06-11 19:12         ` Dmitry A. Kazakov
2011-06-15 10:30       ` Natasha Kerensikova [this message]
2011-06-15 11:10         ` Yannick Duchêne (Hibou57)
2011-06-15 11:19           ` Yannick Duchêne (Hibou57)
2011-06-15 14:59         ` Georg Bauhaus
2011-06-15 15:18           ` Yannick Duchêne (Hibou57)
2011-06-15 16:21             ` Georg Bauhaus
2011-06-12  5: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