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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!news.ecp.fr!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Haskell, anyone? Date: Thu, 19 Nov 2015 15:27:35 -0600 Organization: JSA Research & Innovation Message-ID: References: <14533506-4289-4148-b8c4-e970f5778b26@googlegroups.com> <87si45msuz.fsf@nightsong.com> <35d6dc4f-4f2e-4e75-925c-e4acc7c8f112@googlegroups.com> <76ea0bc9-537b-4c68-a728-4f634cf6de52@googlegroups.com> <87a8qccxj4.fsf@nightsong.com> <0ff849e9-11d7-438d-abf9-853f79348640@googlegroups.com> <874mgjnctv.fsf@nightsong.com> <87ziyblkzn.fsf@nightsong.com> <937b88b1-66aa-4205-a412-9588d83a3f26@googlegroups.com> <36a48f94-41ee-491a-8312-d6e7732bf482@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1447968456 14806 24.196.82.226 (19 Nov 2015 21:27:36 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 19 Nov 2015 21:27:36 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:28471 Date: 2015-11-19T15:27:35-06:00 List-Id: "Hadrien Grasland" wrote in message news:36a48f94-41ee-491a-8312-d6e7732bf482@googlegroups.com... ... >Actually, speaking of functional programming Ada, I'm curious : would there >be an elegant way to produce a higher-order function equivalent in Ada ? > >Ada sure has the very powerful ability to declare functions within >functions, >and it also has function pointers. But due to the way accessibility rules >work, >my understanding is that this would not be enough to implement things like >partial application or containers of functions, because once we leave the >scope of a function, it instantly ceases to exist. > ... >Or have I missed some important language feature which could be used to >this end, like a way to serialize a function and its state to a stream ? Not really. Some of what you're thinking of would work using anonymous access to subprogram parameters (which do not require any accessibility check). That allows passing any function to another one. But as those are limited to parameters, it's hard to keep them around for long. That means they're good for iteration and mapping constructs. Not so much for lazy evaluation or partial application. On a couple of occassions, we've talked about named anonymous access-to-subprogram types (obviously a bad name that would get replaced if something on this line was adopted). Those would have a representation that would have enough information to call a nested subprogram; 'Unchecked_Access would be used to create values (so you'd be on your own to prevent calls to dangling subprograms). That would allow longer term storage of such subprograms (useful for subprograms declared in generic instances or long-lived subprograms like the main subprogram). These haven't gone anywhere. (The usual context is GNAT's 'Unrestricted_Access, a mechanism that cannot be reasonably adopted in other compilers; the GCC memory model makes it possible. Many of us would like something in the language so that 'Unrestricted_Access wouldn't be anywhere near as necessary.) But I don't know of anything on the drawing boards for partial application or similar things. So far as I know, no one has asked (formally or informally). Randy.