From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Tagged type more type safe than access to subprogram ?
Date: Thu, 29 Oct 2009 18:54:19 +0100
Date: 2009-10-29T18:54:16+01:00 [thread overview]
Message-ID: <1hw5s0lijncfx$.ts4hox0vmab3.dlg@40tude.net> (raw)
In-Reply-To: 336a4300-9867-4caf-a8c2-4e75e262e694@l13g2000yqb.googlegroups.com
On Thu, 29 Oct 2009 04:00:29 -0700 (PDT), Hibou57 (Yannick Duchêne) wrote:
> On 28 oct, 09:55, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> 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
next prev parent reply other threads:[~2009-10-29 17:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-28 7:51 Tagged type more type safe than access to subprogram ? Hibou57 (Yannick Duchêne)
2009-10-28 8:55 ` Dmitry A. Kazakov
2009-10-29 11:00 ` Hibou57 (Yannick Duchêne)
2009-10-29 17:54 ` Dmitry A. Kazakov [this message]
2009-10-29 20:45 ` Georg Bauhaus
2009-10-30 8:25 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox