* Procedural Types
@ 2003-10-15 6:59 Umut DURAK
2003-10-15 7:43 ` Dmitry A. Kazakov
0 siblings, 1 reply; 3+ messages in thread
From: Umut DURAK @ 2003-10-15 6:59 UTC (permalink / raw)
Is it possible to define procedural types in ADA95 ? CLearly is it
possible to define procedure type and implement various procedures
with the same type ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Procedural Types
2003-10-15 6:59 Procedural Types Umut DURAK
@ 2003-10-15 7:43 ` Dmitry A. Kazakov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry A. Kazakov @ 2003-10-15 7:43 UTC (permalink / raw)
On 14 Oct 2003 23:59:00 -0700, durakumut@hotmail.com (Umut DURAK)
wrote:
>Is it possible to define procedural types in ADA95 ? CLearly is it
>possible to define procedure type and implement various procedures
>with the same type ?
Unfortunately, no. There are only:
1. pointers to subroutines
2. formal subroutine parameters of generic packages
Thus if you want to pass a subroutine as a parameter you almost always
have to break accessibility checks per brute force, or alternatively
you have to make things generic. Keep also in mind that to pass a
dispatching subroutine is not a trivial task.
---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Procedural Types
@ 2003-10-15 7:02 christoph.grein
0 siblings, 0 replies; 3+ messages in thread
From: christoph.grein @ 2003-10-15 7:02 UTC (permalink / raw)
To: comp.lang.ada
> Is it possible to define procedural types in ADA95 ? CLearly is it
> possible to define procedure type and implement various procedures
> with the same type ?
Strictly speaking, there are no subprogram types (procedure and function types).
Less strictly speaking, a subprogram type is defined by its parameter and return
profile. So any subprogram matching the profile can e.g. be used as an actual
parameter in a generic instantiation.
There are also subprogram access types (pointers). Any subprogram matching the
pointer profile can be assigned to such a pointer (if the access level is
correct).
type P_Pointer is access procedure;
procedure Proc;
P: P_Pointer := Proc'Access;
P.all; -- call Proc
type F_Pointer is access function (X: A_Type) return Another_Type;
function Func (X: A_Type) return Another_Type;
F: F_Pointer := Func'Access;
V := F.all (X); -- call Func
V := F (X); -- call Func (implecit dereference)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-10-15 7:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-15 6:59 Procedural Types Umut DURAK
2003-10-15 7:43 ` Dmitry A. Kazakov
-- strict thread matches above, loose matches on Subject: below --
2003-10-15 7:02 christoph.grein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox