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-Thread: 103376,26a21b9e317dc639 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.81.195 with SMTP id c3mr1528851pay.44.1353535943583; Wed, 21 Nov 2012 14:12:23 -0800 (PST) MIME-Version: 1.0 Path: 6ni4154pbd.1!nntp.google.com!news.glorb.com!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!nuzba.szn.dk!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Access type to member procedure of instance (Object Oriented programming in Ada) Date: Wed, 21 Nov 2012 16:12:21 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <9b0bcb37-8ae3-440f-af4f-a796702e4250@googlegroups.com> <114a6fcf-32c3-408f-961f-2e3bf3c5af04@googlegroups.com> <87af1bfd-41d2-45c7-953a-c1954d4f5ceb@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1353535942 2365 69.95.181.76 (21 Nov 2012 22:12:22 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 21 Nov 2012 22:12:22 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Date: 2012-11-21T16:12:21-06:00 List-Id: "Adam Beneschan" wrote in message news:87af1bfd-41d2-45c7-953a-c1954d4f5ceb@googlegroups.com... >On Tuesday, November 20, 2012 1:38:38 PM UTC-8, Randy Brukardt wrote: >> "Adam Beneschan" wrote in message >> >> >If Message had type Message_Type'Class, I'd assume that at some point, >> >Message.Print'Access would need to determine which Print subprogram >> >would >> >be >> >called, and figure out the address of it. I don't think it matters >> >whether >> >it's done when the >> >'Access value is computed or when the call is made, since the tag of an >> >object can't be >> >changed during the object's lifetime. I could be wrong, though; maybe >> >I've >> >missed a case >> >where it matters. (But I'm not concerned about the possibility of an >> >object's tag being >> >changed through extralegal means like Unchecked_Conversion.) >> >> I don't think this is quite true; if the object is a parameter (for >> instance), it can have different tags for different calls. But I don't >> see >> that happening for something like Param.Print'Access -- access values are >> never dispatching. >> >> Anyway, since something like Param.Print'Access is illegal in any case, >> we >> don't have to decide what this means or how code would be generated for >> it. > >I probably confused things. Yes, Param.Print'Access is illegal, but I was >thinking in terms of "what if" we added a language feature to make it >legal--probably >by adding a new kind of access type that contained references both to the >prefix >object and, somehow, to the subprogram. In that case, I'd want it to be >dispatching, if Param's type were classwide. *IF* we made it legal, we'd simply change the convention to Ada. There is no reason for the complication of a new kind of access type, because creating a wrapper is simple. Moreover, both Ada 2005 and Ada 2012 require creating wrappers in certain circumstances, so it's not like this is something a compiler never has done before. (And there are at least 4 other places where Janus/Ada uses wrappers, it's just not a big deal. And one of them is for 'Access when the subprogram was declared inside a generic while the access type was not.) Note that GNAT is apparently using a wrapper to implement the renames of a prefixed view (and mistakenly allowing 'Access to be taken of the result). Doing exactly that for 'Access is not likely to be a big deal. Whether or not that wrapper ought to dispatch is a separate issue and probably doesn't really make any difference to how the 'Access is supported. Randy.