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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, XPRIO autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b74ec64483660e21,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-23 14:18:41 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!psiuk-p2!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: When to use 'Class in a parameter list Date: Mon, 23 Jul 2001 16:27:14 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9ji1b3$4pi$1@nh.pace.co.uk> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 995920035 4914 136.170.200.133 (23 Jul 2001 20:27:15 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 23 Jul 2001 20:27:15 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-Mimeole: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:10482 Date: 2001-07-23T20:27:15+00:00 List-Id: O.K. Here's something I thought I understood but given behavior of some code I have, now I'm questioning what is happening. If I have a tagged type "Base_Type" that has an operation on it, called "Op" and I derive a new type called "Child_Type" that does not require changes to "Op", do I make the parameter Base_Type or Base_Type'Class? (My understanding was that I could make it Base_Type, but then calls to it with a Child_Type would require explicit type conversion. Making it 'Class would accept anything of that class without conversion. Apparently the compiler is swollowing it without type conversion - which is now confusing me.) In code: procedure Op (Base : in out Base_Type) ; ... X : Child_Type ; ... Op (X) ; -- Why is this working without a Base_Type (X) conversion??? So unless I'm doing something strange that is causing some corner-case to come up, I'm now wondering why I would need Base_Type'Class as a parameter type? I was under the impression that I would use 'Class if I wanted to make an operation that worked on anything derived from the class without explicit conversion. (Possible to override it in a child class, AFAIK...) My understanding of when to *NOT* use the 'Class was if I was building an operation I expected to override (possibly calling the parent operation within it - using a type conversion). So when it is not overriden, and control goes to the parent op without an explicit conversion, then when do you need the 'Class? I must be missing something here......(I need to do this sort of thing more often - it all evaporates if you don't use it!!!) MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/