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: a07f3367d7,26a21b9e317dc639 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.180.141 with SMTP id bu13mr8923566qab.2.1353341926979; Mon, 19 Nov 2012 08:18:46 -0800 (PST) Received: by 10.49.75.9 with SMTP id y9mr717688qev.9.1353341926953; Mon, 19 Nov 2012 08:18:46 -0800 (PST) Path: gf5ni1407qab.0!nntp.google.com!u2no13048766qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 19 Nov 2012 08:18:46 -0800 (PST) In-Reply-To: <9b0bcb37-8ae3-440f-af4f-a796702e4250@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <9b0bcb37-8ae3-440f-af4f-a796702e4250@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <49cdda31-d0bd-42f2-8076-65504105d07e@googlegroups.com> Subject: Re: Access type to member procedure of instance (Object Oriented programming in Ada) From: Adam Beneschan Injection-Date: Mon, 19 Nov 2012 16:18:46 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-11-19T08:18:46-08:00 List-Id: On Monday, November 19, 2012 1:59:42 AM UTC-8, ake.ragna...@gmail.com wrote= : > Not sure if this has already been discussed but: Is it possible to define= a pointer to a member procedure of an instance? No, I don't think so. I've been thinking about proposing an addition to Ad= a to do something like this, since I think this feature does exist in other= languages (C# delegates, in particular; I don't know C++ well enough to kn= ow whether there's something similar there). =20 Ada already has "access protected procedure", in which an access object has= to have both a reference to the code being called and a reference to the (= protected) object being operated on. So at first glance it seems like addi= ng a new kind of access type "access blahblah procedure" (perhaps "access t= agged procedure", if we want to avoid defining a new reserved word), where = the access object has both a reference to the subprogram code and a referen= ce to the object being operated on, wouldn't be too difficult. My thinking= here is that if you say Obj.Op'access, and Obj has a class-wide type, then= an indirect call through the access type would dispatch to the correct Op.= The tricky thing is figuring out whether it would play nice with other la= nguage features, such as pre-/post-conditions. =20 Unlike the other posters here, I haven't studied your example to see whethe= r it is really a good example of a case where a feature like this is needed= , or whether there's a good enough workaround using existing Ada features t= o solve your particular problem. -- Adam