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-07 02:06:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!195.158.233.21!news1.ebone.net!news.ebone.net!lnewspeer00.lnd.ops.eu.uu.net!lnewspost00.lnd.ops.eu.uu.net!emea.uu.net!not-for-mail From: "David Crocker" Newsgroups: comp.lang.ada References: <3be800d3$0$230$ed9e5944@reading.news.pipex.net> Subject: Re: 'withing' problem Date: Wed, 7 Nov 2001 10:11:22 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Message-ID: <3be907bc$0$233$ed9e5944@reading.news.pipex.net> NNTP-Posting-Host: andrew.imsltd.com X-Trace: 1005127612 reading.news.pipex.net 233 194.202.27.87 X-Complaints-To: abuse@uk.uu.net Xref: archiver1.google.com comp.lang.ada:15978 Date: 2001-11-07T10:11:22+00:00 List-Id: wrote in message news:io%F7.3554$Mt6.1856123@news1.rdc1.sfba.home.com... > 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? It is usual in OO languages for all classes to derive from a base class. One of the reasons is that it lets you write things like: procedure print(x: anything'class, ...) The implementation of 'print' would call 'toString(x)' and output the result. So I can use 'print' to print any object I like, and provided the declaration of the class concerned has overridden the 'toString' method, the result will make sense (if the class didn't override 'toString', the default implementation in 'anything' will yield "unprintable object" or something like that). > Actually it's the declaration of "toString" that needs a preceding declaration of "seq". Correct. But the declaration of 'toString' needs to be in the package for 'anything', so the package for 'anything' needs to 'with' the package for 'seq', and vice versa. > 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. This looks viable, but it means that 'seq' and 'anything' must be declared in the same package. Unfortunately, every cross-dependency results in the classes concerned having to be placed in the same package, so before long you end up with the whole program being in a single package. What we would like is that each class in the original language becomes a separate package in Ada. Thanks for your input. David Crocker, Escher Technologies Ltd. www.eschertech.com