* Can Ada95 features replace the use of Ada 83 Varient records?
@ 1998-08-21 0:00 Mark
1998-08-21 0:00 ` David C. Hoos, Sr.
1998-08-30 0:00 ` Matthew Heaney
0 siblings, 2 replies; 3+ messages in thread
From: Mark @ 1998-08-21 0:00 UTC (permalink / raw)
-- I'm new to Ada95 (Familar with 83) and thought that the use
-- of varient records in Ada 83 can be replaced by Tagged types.
-- Is it possible to implement the following using Ada 95 features?
package Test is
type Large_Data_Type is new Integer; -- large record normally
type Rec (Changed : Boolean := False) is
record
case Changed is
when TRUE =>
Data : Large_Data_Type;
when FALSE =>
null;
end case;
end record;
function Get return Rec;
end Test;
-- with Some_Other_Package;
package body Test is
Large_Data : Large_Data_Type := 1;
function Get return Rec is
Outside_Event : Boolean := false;
-- Outside_Event : constant Boolean :=
Some_Other_Package.Event_Occured;
begin
case Outside_Event is
when True =>
return (
Changed => True,
Data => Large_Data);
when False =>
return (Changed => False);
end case;
end Get;
end Test;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Can Ada95 features replace the use of Ada 83 Varient records?
1998-08-21 0:00 Can Ada95 features replace the use of Ada 83 Varient records? Mark
@ 1998-08-21 0:00 ` David C. Hoos, Sr.
1998-08-30 0:00 ` Matthew Heaney
1 sibling, 0 replies; 3+ messages in thread
From: David C. Hoos, Sr. @ 1998-08-21 0:00 UTC (permalink / raw)
Mark wrote in message <01bdcd2f$a7da71f0$0f010180@nc84c>...
>-- I'm new to Ada95 (Familar with 83) and thought that the use
>-- of varient records in Ada 83 can be replaced by Tagged types.
>
>-- Is it possible to implement the following using Ada 95 features?
>
See the files on my FTP site in:
ftp://ftp.ada95.com/pub/tagged_types
The main program is test_messages.
This is just a contrived example for proof of concept.
Hope this helps,
David C. Hoos, Sr.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Can Ada95 features replace the use of Ada 83 Varient records?
1998-08-21 0:00 Can Ada95 features replace the use of Ada 83 Varient records? Mark
1998-08-21 0:00 ` David C. Hoos, Sr.
@ 1998-08-30 0:00 ` Matthew Heaney
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Heaney @ 1998-08-30 0:00 UTC (permalink / raw)
"Mark" <mark@lourow.demon.co.uk> writes:
> -- I'm new to Ada95 (Familar with 83) and thought that the use
> -- of varient records in Ada 83 can be replaced by Tagged types.
>
> -- Is it possible to implement the following using Ada 95 features?
Here you go:
package Test is
type Large_Data_Type is new Integer; -- large record normally
type Rec_Type is tagged null record;
type Changed_Rec_Type is
new Rec_Type with record
Data : Large_Data_Type;
end record;
function Get return Rec_Type'Class;
end Test;
package body Test is
Large_Data : Large_Data_Type := 1;
function Get return Rec_Type'Class is
Outside_Event : Boolean := false;
begin
case Outside_Event is
when True =>
return Changed_Rec_Type'(Data => Large_Data);
when False =>
return Rec_Type'(null record);
end case;
end Get;
end Test;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-08-30 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-21 0:00 Can Ada95 features replace the use of Ada 83 Varient records? Mark
1998-08-21 0:00 ` David C. Hoos, Sr.
1998-08-30 0:00 ` Matthew Heaney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox