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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,26a21b9e317dc639,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Received: by 10.224.220.136 with SMTP id hy8mr8282300qab.3.1353319182922; Mon, 19 Nov 2012 01:59:42 -0800 (PST) Received: by 10.49.130.106 with SMTP id od10mr2310130qeb.20.1353319182888; Mon, 19 Nov 2012 01:59:42 -0800 (PST) Path: gf5ni1407qab.0!nntp.google.com!u2no12342297qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 19 Nov 2012 01:59:42 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=136.163.203.8; posting-account=l8k8IwoAAADeDydswOzwNzmn10qOk9gt NNTP-Posting-Host: 136.163.203.8 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9b0bcb37-8ae3-440f-af4f-a796702e4250@googlegroups.com> Subject: Access type to member procedure of instance (Object Oriented programming in Ada) From: ake.ragnar.dahlgren@gmail.com Injection-Date: Mon, 19 Nov 2012 09:59:42 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-11-19T01:59:42-08:00 List-Id: Not sure if this has already been discussed but: Is it possible to define a= pointer to a member procedure of an instance? This problem has it's origin in the implementation of the MVC pattern for a= GtkAda application. Consider the following: package Some_Package is type Message_Type is tagged null record; =20 procedure Print(Message : Message_Type); end Some_Package; package body Some_Package is procedure Print (Message : Message_Type) is begin null; end Print; end Some_Package; Then it is possible to create the following Main application that compiles = just fine: with Some_Package; procedure Main is Message : Some_Package.Message_Type; begin Message.Print; end Main; Is it possible to create a parameterless access type to the Message.Print p= rocedure? The following application refuses to compile: with Some_Package; procedure Main is Message : Some_Package.Message_Type; =20 Method_Ref : access procedure :=3D Message.Print'Access; begin Method_Ref; end Main; The error message is: no selector "Print" for type "Message_Type" defined a= t some_package.ads:3 It is possible to create a workaround: with Some_Package; procedure Main is Message : Some_Package.Message_Type; =20 procedure Method_Ref is begin Message.Print; end Method_Ref; =20 begin Method_Ref; end Main; Is there a better way? Or is this the optimal way? Regards, =C5ke Ragnar Dahlgren