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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,99f33f51845a7793 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-06 16:38:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed1.uncensored-news.com!propagator-la!news-in-la.newsfeeds.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: 'withing' problem References: <3be800d3$0$230$ed9e5944@reading.news.pipex.net> X-Newsreader: Tom's custom newsreader Message-ID: Date: Wed, 07 Nov 2001 00:38:38 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 1005093518 24.7.82.199 (Tue, 06 Nov 2001 16:38:38 PST) NNTP-Posting-Date: Tue, 06 Nov 2001 16:38:38 PST Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:15963 Date: 2001-11-07T00:38:38+00:00 List-Id: > Using the Ada-like notation of your example, 'toString' dispatches on the > type of parameter x. In fact, the call is written 'expr.toString' as in > other OO languages, so (unlike the case in Ada) it is obvious what the call > dispatches on. Actually, it's not the case that function toString(x : anything) return seq; shows an ambiguity about dispatching in Ada, since it's not (legal) Ada. > We define a base class 'anything' from which all other classes derive (like > Java's 'Object'). This base class has an abstract method 'toString' (just > like Java) having a return type 'seq of char' (where 'seq' is a templated > type representing a sequence). But 'seq' is, like all other classes, derived > from 'anything'. Does "seq" have any children? Does it inherit things from "anything"? Given "x : seq;", what does "toString(x);" produce? More generally, why is "seq" derived from "anything" rather than just standing on its own? > So the declaration of 'anything' needs to see a forward declaration of 'seq'. Actually it's the declaration of "toString" that needs a preceding declaration of "seq". How about type anything is tagged null record; type seq is new anything with record ... end record; function toString(x:anything'class) return seq; and then use overloading to create function toString(x : first_child_of_anything'class) return seq; function toString(x : second_child_of_anything'class) return seq; function toString(x : first_of_first_child_of_anything'class) return seq; etc. Then calls look like a_seq := first_child.toString(x); a_seq := second_child.toString(y); a_seq := first_of_first_child.toString(x);