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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2078ce7aac45af5b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.87.234 with SMTP id bb10mr927192pab.36.1353056367504; Fri, 16 Nov 2012 00:59:27 -0800 (PST) Path: s9ni19274pbb.0!nntp.google.com!news.glorb.com!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada202X : Adding functors Date: Fri, 16 Nov 2012 09:59:35 +0100 Organization: cbb software GmbH Message-ID: <1nns2z6uw5q7m.1vv6s1jevxoqb.dlg@40tude.net> References: <0114d327-9f9f-4ad2-9281-56331d11a90c@googlegroups.com> <15w6caje3zsh$.t5nqtwoa77x5$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-11-16T09:59:35+01:00 List-Id: On Thu, 15 Nov 2012 19:01:28 -0500, Peter C. Chapin wrote: > On 11/15/2012 12:04 PM, Dmitry A. Kazakov wrote: > >> Anyway, the issue is that functions are intimately related to the types of >> their arguments and results as primitive operations. Non-first class >> functions are singletons which ensures 1-1 mapping between the operation >> and the argument/result type. First-class functions would break that >> correspondence. > > I guess I'm not understanding what you mean here. type T is tagged ... procedure Operation (X : T); There is only one instance of Operation for T. This is easy when Operation is not an object. Once you make it an object, there could possibly be more than one instance of. X : T'Class; begin X.Operation; -- Which one instance is called here? Dispatching tables shall be checked statically, they shall have only one operation in a slot etc. >> It is also unclear what happens with the operations defined on functional >> objects. What will be the types of function functions (functionals)? It is >> an infinite recursion of higher-order functions to stop somewhere. > > If you have higher order functions then you will have a way to write > function types. For example, in Scala: > > def filter(someList: List[Int], predicate: Int => Boolean) = ... > > This defines a function 'filter' that takes a list of integers and a > function from Int to Boolean. The notation 'Int => Boolean' is a > function type. And yes, you can write types like > > (Int => Boolean) => String > > for functions taking a (function from Int to Boolean) and returning > String. It's no big deal. Can I inherit it? Override it? Which are the classes of types (Int => Boolean) => String operates on? > After all you can use access to access types > in Ada. Yes. It puzzled me for years why we still cannot do it without access: type Integer_To_Boolean is function (X : Integer) return Boolean; But this is not same as functions being first-class with all bells and whistles. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de