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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9e5d694241060c24 X-Google-Attributes: gid103376,public From: je@bton.ac.uk (John English) Subject: Re: Tagged types and static dispatching Date: 1996/12/05 Message-ID: <586rp8$l9o@saturn.brighton.ac.uk>#1/1 X-Deja-AN: 202516024 references: <32A2E972.28AF@masda.hv.se> organization: University of Brighton newsgroups: comp.lang.ada Date: 1996-12-05T00:00:00+00:00 List-Id: Tobias Ritzau (Tobias.Ritzau@masda.hv.se) wrote: : I have some trouble understanding some featers of Ada 95. I wrote a : small package with a linked list and a list iterator. Of course I wanted : the types to be tagged so that I could expand them later on. When I : compiled my package I got an error message saying: : operation can be displatching in only one type Yes, since you have the two tagged types declared in the same pacakge spec, you're asking the compiler is trying to make Restart a primitive operation of *both* types. Possible solutions: 1) Make ListIt non-tagged, so Restart only has one tagged parameter and so is only a primitive of List (as you found out) 2) Use a class-wide parameter so again Restart has only one tagged parameter and is only a primitive of List 3) Declare the types in different package specifications so Restart is only a primitive of the type declared in the same specification. The advantage of (2) is that you can do double dispatching (selecting a primitive operation based on two independent tagged values) like so: procedure Restart(I : in out ListIt'Class; L : in List) is -- calls dispatch to the appropriate version of Restart depending -- on the actual type of L begin ListIt_Primitive(I); -- dispatches to the appropriate -- ListIt operation depending on -- the actual type of I end Restart; --------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.comp.it.bton.ac.uk/je Dept. of Computing | fax: (+44) 1273 642405 University of Brighton | ---------------------------------------------------------------