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: a07f3367d7,bde430ece5c51468 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!85.158.31.10.MISMATCH!newsfeed-0.progon.net!progon.net!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Tagged type more type safe than access to subprogram ? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <336a4300-9867-4caf-a8c2-4e75e262e694@l13g2000yqb.googlegroups.com> Date: Thu, 29 Oct 2009 18:54:19 +0100 Message-ID: <1hw5s0lijncfx$.ts4hox0vmab3.dlg@40tude.net> NNTP-Posting-Date: 29 Oct 2009 18:54:16 CET NNTP-Posting-Host: 09ab57b0.newsspool4.arcor-online.net X-Trace: DXC=M8Q@Waao5T4;]cDoEWD6A44IUKCOgUkn_?_Y?Pd616iaF;3;FGV@7YCQ\B7 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8846 Date: 2009-10-29T18:54:16+01:00 List-Id: On Thu, 29 Oct 2009 04:00:29 -0700 (PDT), Hibou57 (Yannick Duchêne) wrote: > On 28 oct, 09:55, "Dmitry A. Kazakov" > wrote: >> An access to subprogram is a poor-man's closure. Let's ignore "access" part >> and consider a pure downward closure (as it should have been in Ada). > “ As this should have been in Ada ” ? What were you to mean ? I've > always though real closures are not possible with such structures as > Ada provides, except at package level — which is especially the case > when a package can have multiple instances... but only at package > level. Isn't it ? I meant downward closures. There is no reason for type P is access procedure (...); where actually meant type P is procedure (...); It is almost always safer and cleaner to pass subprograms instead of access to them. Obviously a subprogram type were a limited type, so a subprogram were passed by reference. A pointer were only needed when you wanted to copy it. And copying pointers is always asking for trouble... BTW, in Ada 83, there waa no access to subprogram, so we used tasks instead (where a subprogram had to be a non-generic parameter). Task is a proper type since the day one. Subprograms lingered, but then in Ada 95 one did a big mistake introducing access discriminants, access to subprogram, access to self (the Rosen trick), access to function's mutable parameter etc. And almost in all use cases of these, no access is actually needed. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de