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,2078ce7aac45af5b,start 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 bu13mr8245031qab.2.1352758155884; Mon, 12 Nov 2012 14:09:15 -0800 (PST) Received: by 10.52.175.73 with SMTP id by9mr4096724vdc.1.1352758155857; Mon, 12 Nov 2012 14:09:15 -0800 (PST) Path: gf5ni18188417qab.0!nntp.google.com!c7no22761611qap.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 12 Nov 2012 14:09:15 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=92.235.245.78; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G NNTP-Posting-Host: 92.235.245.78 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0114d327-9f9f-4ad2-9281-56331d11a90c@googlegroups.com> Subject: Ada202X : Adding functors From: Martin Injection-Date: Mon, 12 Nov 2012 22:09:15 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-11-12T14:09:15-08:00 List-Id: I'm increasingly using functors in my C++ life and they are very cool. I'd like to be able to use them in my Ada life too but the language doesn't support it - or can someone tell me I'm wrong? I think it could be done by 'simply' allowing something like this: package P is type T is tagged ...; function Create return T; procedure "()" (This : T; I : Integer); -- The functor call function "()" (This : T) return Integer; -- Alternative functor that's a function private ... end P; with P; procedure Demo is My_T : P.T := P.Create begin My_T (42); -- call to procedure version if My_T () > 100 then ... end if; -- call to function version end Demo; I guess one of the trickier bits of adding this would be the possible need to step away from the current Ada convention of not requiring empty parenthesis...but new language revisions always change the 'current' good style... Any thoughts? -- Martin