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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,87077e61d6b3095b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-22 15:23:21 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: cl1motorsports Newsgroups: comp.lang.ada Subject: Re: how do i implement double-dispatching? Date: Mon, 22 Dec 2003 18:04:52 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-Id: User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity. (Debian GNU/Linux)) References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:3725 Date: 2003-12-22T18:04:52-05:00 List-Id: On Mon, 22 Dec 2003 17:49:41 -0500, Stephen Leake wrote: > cl1motorsports writes: > >> Okay. now it works when the Visitor type, Visit() procedures and the >> Accept_Visitor() procedure is in a separate package from the parse tree. >> but when i try to combine the 2 into one package i get >> an error about multiple dispatching on all of the Visit() procedures. >> what is my scope issue with being in the same package that doesn't apply >> to them being in 2 packages? > > In general, you will find that the Ada rules encourage putting things > in different packages. This is a Good Thing :). But in this case there is no point of having a visitor with out a tree to visit or a parse tree with no visitor to run operations on it. Currently to use this in a program i have to do this: with Parse_Tree_Pkg; use Parse_Tree_Pkg; with Abstract_Visitor_Pkg; use Abstract_Visitor_Pkg; with Interpret_Tree; use Interpret_Tree; a person using the interpret_Tree package having to know that it's created from an abstract visitor package exposes implementation and that's what I am trying to avoid. The user should only have to do: with parse_tree_pkg; use parse_tree_pkg; with Interpret_Tree; use interpret_Tree; am i correct on this or am i missing something? > > Sometimes child packages work better.