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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,57c2a52b53b360c2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news3.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Re: Multiple dispatch Date: Wed, 15 Jun 2011 10:30:43 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <7loar137gjid$.qrn6ghii6ee$.dlg@40tude.net> <11peqoimzzkd9$.foyzy9udb4dt$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 15 Jun 2011 10:30:43 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="Mda950WjNwNLAFOE7yJXQw"; logging-data="2654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YXKIMKpu7fw/GL++01LDt" User-Agent: slrn/0.9.9p1 (FreeBSD) Cancel-Lock: sha1:QD4XI8fWoRaQYmq0QnAokoSgThM= Xref: g2news1.google.com comp.lang.ada:19844 Date: 2011-06-15T10:30:43+00:00 List-Id: Hello, On 2011-06-11, Dmitry A. Kazakov 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 >> 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