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,a270a1fc28d4f812 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-01 04:48:50 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!snoopy.risq.qc.ca!aotearoa.belnet.be!news.belnet.be!newsfeed.stueberl.de!news2.euro.net!transit.news.xs4all.nl!not-for-mail From: Fraser Wilson Newsgroups: comp.lang.ada Subject: Re: OOD in Ada? Date: 01 Jul 2002 13:50:14 +0200 Organization: XS4ALL Internet BV Sender: fwilson@FWILSON Message-ID: References: <3d135676$0$8511$cc9e4d1f@news.dial.pipex.com> <3d1870b0$0$8507$cc9e4d1f@news.dial.pipex.com> NNTP-Posting-Host: a80-126-24-12.adsl.xs4all.nl X-Trace: news1.xs4all.nl 1025524128 15939 80.126.24.12 (1 Jul 2002 11:48:48 GMT) X-Complaints-To: abuse@xs4all.nl NNTP-Posting-Date: 1 Jul 2002 11:48:48 GMT X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:26794 Date: 2002-07-01T11:48:48+00:00 List-Id: "Randy Brukardt" writes: > This is a fine solution, but it runs into a problem in use: essentially > every reference to anything will need a type conversion to the "real" > type in order to access the operations/components. There's a certain amount of that, yes. But most of the work is done with dispatch: one subprogram does the semantic analysis, another does the code generation, and most of the time you can make the call without worrying about what the tree node really is (even if you secretly know). For example, an if statement node has an element called "Condition", and when checking an if statement, a call like Check (If_Statement.Condition) suffices. You know and I know that it's really an expression, but I don't have to encode that knowledge. In general, the parse tree has been able to avoid type conversions; the other class hierarchies (symbol table entries and types) aren't so pretty. Dispatching operations on the root tree node type have to be carefully chosen of course. And that can get a bit silly: in the class hierarchy for symbol table entries, one of the operations is "Push_Address" which only makes sense for variables and subprograms, so any time you call this operation you have to know what you have. Perhaps a conversion is better in this case, to make that knowledge explicit (since unlike the parse tree, it's being relied upon). cheers, Fraser.