* default generic parameter ?
@ 2005-03-17 2:43 Bini
2005-03-17 3:55 ` Marius Amado Alves
0 siblings, 1 reply; 3+ messages in thread
From: Bini @ 2005-03-17 2:43 UTC (permalink / raw)
generic
type Item is private;
with procedure Item_Destroy(I : out Item) := null; -- Invalid syntax...
package List is
type List is limited private;
type List_Element is limited private;
.
.
. -- procedure and function for List ...
.
private
type List_Element_Record;
type List_Element is access List_Element_Record;
type List_Element_Record is record
Data : Item_T;
Next : List_Element := null;
end record;
type List_Record is record
Size : Natural := 0;
Head : List_Element := null;
Tail : List_Element := null;
end record;
type List is access List_Record;
package body List is
procedure List_Destroy(Lst : in out List)
Tmp : Item;
begin
.
.
while Lst.Size /= 0 loop
.
.
if Item_Destroy /= null then
Item_Destroy(Tmp);
end if;
.
.
end loop
Free(Lst);
end List_Destroy;
.
.
Of course this code is Invalid
But I want to make default generic formal parameter(?)...
How I can do it?
I am not a native speaker of English. I am sorry...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: default generic parameter ?
2005-03-17 2:43 default generic parameter ? Bini
@ 2005-03-17 3:55 ` Marius Amado Alves
2005-03-17 8:22 ` Bini
0 siblings, 1 reply; 3+ messages in thread
From: Marius Amado Alves @ 2005-03-17 3:55 UTC (permalink / raw)
To: Bini; +Cc: comp.lang.ada
On 17 Mar 2005, at 02:43, Bini wrote:
> generic
> type Item is private;
> with procedure Item_Destroy(I : out Item) := null; -- Invalid
> syntax...
There is this construct:
generic
with procedure Op is <>;
but then on instantiation a matching procedure must exist. I think to
do what you want you must write:
type Op_Ptr is access procedure;
generic
Op : Op_Ptr := null;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-03-17 8:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-17 2:43 default generic parameter ? Bini
2005-03-17 3:55 ` Marius Amado Alves
2005-03-17 8:22 ` Bini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox