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,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4687ad82921cf6ad,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-15 11:28:31 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!c03.atl99!sjc70.webusenet.com!news.webusenet.com!sn-xit-02!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "cl1" Newsgroups: comp.lang.ada Subject: issue with implementing a visitor design pattern Date: Thu, 15 Jan 2004 13:22:32 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <100dqeul3pqiua0@corp.supernews.com> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:4443 Date: 2004-01-15T13:22:32-06:00 List-Id: i'm trying to implement a visitor pattern for a parse tree(its a simple calculator at this point). i have an abstract type: type Visitor_Record is abstract tagged null record; with primative operations Visit() for each node type like so: Visit(V : in out Visitor_Record; Node : in Add_Op'Class) is abstract; ... Visit(V : in out Visitor_Record; Node : in Assignment_Node'Class) is abstract; what i'm trying to do is implement a Preorder_Visitor_Record type that uses the Visit() operation to traverse the tree and calls an operation Visit_Operation() that is also a primative operation on Preorder_Visitor_Record like so: with parse_tree_pkg; use parse_tree_pkg; -- has the parse tree nodes a primative operation Accept_Visitor() for each node -- and the abstract Visitor_Record with primative operations Visit() for each node package Preorder_Visitor_Pkg is type Preorder_Visitor_Record is new Visitor_Record with null record; -- this is overidiing the abstract version in parse_tree_pkg; procedure Visit ( V : in out Preorder_Visitor_Record; Node : in Add_Op'Class); ..... procedure Visit_Operation (V : in preorder_Visitor_Record; node : in add_op'class); end preorder_visitor_Pkg; package body Preorder_Visitor_Pkg is procedure Visit_Operation ( V : in out Preorder_Visitor_Record; Node : in Add_Op'Class) is begin raise Not_Implemented; -- better handling in actual code with an error message using ada.exceptions end Visit_Operation procedure Visit( V : in out Preorder_Visitor_Record; Node : in Add_Op'Class) is begin Visit_Operation(V, Node); end Visit; the actual code errors saying ambiguos call of Visit_Operation() from within the Visit() procedure. with possible interpretations at the definition of Preorder_Visitor_Record and at the specification for Visit_Operation. the code works when you take Visit_Operation out of the mix. the package compiles and works with a test driver. but when i try to add in this Visit_Operation it doesn't work. I don't know if there are some scoping issues or if there is something else i need to know about primative operations to make this work. any guidance would be appreciated. Thanks, Charles Lambert