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-19 22:46:54 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: Sat, 20 Dec 2003 00:27:19 -0600 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:3609 Date: 2003-12-20T00:27:19-06:00 List-Id: On Wed, 17 Dec 2003 12:08:41 -0600, cl1motorsports wrote: > package body Abstract_Visitor is > > procedure Accept_Visitor(V : in out Visitor_Record'Class; Node : in Parse_Tree_Node_Record'Class) is > begin > Visit(V, Node); > end Accept_Visitor; > > end Abstract_Visitor; > > -- END OF CODE thanks for all of your suggestions. after careful consideration i decided to change the above Accept_Visitor procedure to: procedure Accept_Vistor(V:in out Visitor_Record'Class; Node : in Parse_Tree_Node_Record'Class) is begin if Node in Equal_Op'Class then Visit(V, Equal_Op(Node)); elsif Node in Number_Node'Class then Visit(V, Number_Node(Node)); ... end if; end Accept_Visitor; now it only dynamically dispatches on the Visitor_Record'Class and the Node parameter is determined at compile time. I don't think i would have figured that out by myself (at least not at this point in time). and just to let y'all know. I'm trying to write a C to Ada translator. The first task on my list is to handle #define statements. I'm sure this should be in another thread if a topic gets started on this. But I thought it would be nice to let y'all know what you were helping me with here. Thanks again everyone [:^)