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,de7dd126d6737f3a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!news2.euro.net!newsfeed.freenet.ag!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Callback in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <8lc2d0Fb6jU1@mid.individual.net> <4cf0ec67$0$6882$9b4e6d93@newsspool2.arcor-online.net> <393221c0-ac56-436f-b3f8-280c40d5a53a@j1g2000vbl.googlegroups.com> <10p6vzd761rdz$.1gtmc0fk6t9rb.dlg@40tude.net> Date: Tue, 30 Nov 2010 09:38:16 +0100 Message-ID: NNTP-Posting-Date: 30 Nov 2010 09:38:16 CET NNTP-Posting-Host: 6cd5ac97.newsspool4.arcor-online.net X-Trace: DXC=2kCAm5gBQ[5gP]QSEBQ^d44IUK7enW;^6ZC`4\`mfM[68DC3PB0O0h[OLY9 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15708 Date: 2010-11-30T09:38:16+01:00 List-Id: On Mon, 29 Nov 2010 19:32:55 -0600, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:10p6vzd761rdz$.1gtmc0fk6t9rb.dlg@40tude.net... > ... >> P.P.S. As Ada strives to introduce procedural-literals, e.g. conditional >> expressions, fancy quantified expressions and other awful stuff, it will >> inevitably require subprogram types, because you cannot get pointer of a >> literal. What is all this mess worth of if it cannot be given as a >> parameter? > > No problem here, just use an expression function to give your expression a > name (and parameters); then you can use 'Access just fine. Forget anonymous > stuff, it only leads to heartache. :-) Agree. BTW, this is another problem with access to subprogram types. Though the type might be explicit the type of the object (subprogram) is implicit. When passing a name in many cases you get a cryptic messages, because the anonymous type is matched against the access type. In presence of overloaded generic instances it becomes a nightmare. This is the case in GtkAda signal handlers, for example. If there were procedural types, things would be explicit: type Call_Back is procedure (...) procedure Do_Something (Action : Call_Back); ... My_Call_Back : constant Call_Back := -- I know this will always match begin ... end My_Call_Back; The syntax must be improved, but the idea is clear: My_Call_Back is explicitly declared of being of the Call_Back type. > [The only exception is anonymous access-to-subprogram, and that is because > of the special closure semantics. It would have been better to use a keyword > to get that semantics, something like: > type Local_Sub is local access function (A : Integer) return Integer; > but this isn't sufficiently broken for such a change.] If an object were passed instead of the pointer, there would be no this problem at all. Pointers considered harmful. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de