home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!gatech!darwin.sura.net!mips!think.com!linus!linus.mitre.org!mbunix.mitre.org!costello
- From: costello@mbunix.mitre.org (Costello)
- Subject: ADT functions working with multiple derived types
- Message-ID: <1992Aug14.184008.8484@linus.mitre.org>
- Sender: news@linus.mitre.org (News Service)
- Nntp-Posting-Host: mbunix.mitre.org
- Organization: The MITRE Corp., Bedford, Ma.
- Distribution: usa
- Date: Fri, 14 Aug 1992 18:40:08 GMT
- Lines: 59
-
- Hi Folks,
- I have created an Abstract Data Type (ADT). That is, I have a package
- that declares a type and functions which work on that type. Now, I can
- derive from that ADT type and then all of those functions are available
- to me with the new type. This works fine.
-
- The problem arises when, in the ADT package, I declare two types and
- have functions which work on both types. When I then do my deriving I
- derive on both types. Now, when I invoke the function which is supposed
- to work on both types I get a compiler error:
-
- >>>>SEMANTIC : Unresolvable expression <8.3, 8.7>
-
- I have concluded that ADTs can only work on one type. Is this correct?
-
- Here is an example. Suppose we have the ADT called junk:
-
- package junk is
- subtype one is integer range 1..10;
- type two is record
- x : integer range 1..20;
- end record;
- function p (a : one) return two;
- end junk;
-
- package body junk is
- function p (a : one) return two is
- r : two;
- begin
- r.x := a;
- return r;
- end p;
- end junk;
-
- Here is a procedure to test the ADT:
-
- with junk; use junk;
-
- procedure p_test is
- type new1 is new one;
- type new2 is new two;
- g: new1;
- h : two;
- begin
- g := 5;
- h := p(g);
- end p_test;
-
- When I compile this procedure I get the above error message.
- Note that when I change the second assignment statement to:
-
- h := two(p(g));
-
- then I don't get the compiler error. If you could shed some
- light on this I would appreciate it. Please send replies to:
-
- costello@mitre.org
-
- Thanks. /Roger
-