comp.lang.ada
 help / color / mirror / Atom feed
* Discriminants & limited privates - yuk?
@ 1991-07-12 22:17 munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!phillip.edu.au!x01233
  0 siblings, 0 replies; only message in thread
From: munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!phillip.edu.au!x01233 @ 1991-07-12 22:17 UTC (permalink / raw)


Hello.


I have a question -  just HOW do i assign a value to a record with a
discriminant and a limited private component?

As I wish to set the value of the discriminant I have to use an aggregate(?),
which requires specifying values for all the components. The catch is that 
one component is limited private, and they can't appear in aggregates,
can they?


The procedure set (see below) must decide the value of the discriminant
(preferably the parameter would be an 'out' parameter,but that's a no-no) so 
its not acceptable to say that the discriminant should already have the 
required value.


Code that won't compile shown below...
---------------------------------------------------------------------------
-- define a limited private type and constant.

package lp is
	type blob is limited private;
	
	jelly	:constant blob;

private
	type blob is new integer;
	jelly	:constant blob:=42;
end lp;

---------------------------------------------------------------
with lp;	use lp;

procedure test is

	type enum_type is (a,b,c);

	type discriminant_record(discriminant:enum_type:=a) is
		record
			case discriminant is
			when a=>	
				item	:blob;
			when others=>
				null;
			end case;
		end record;


	item	:discriminant_record;

	---------------------------------------------------------------
	procedure set(	value	:in out	discriminant_record) is
	begin
		value:=(a,jelly);

			^^^^^^^^ Of course assignment is not available
				 for limited private types, so this is 
				 a no-no, but just how does 'value' get
				 a value?

	end;


begin
	set(item);
end;


------------------------------------------------------------------------------

Thanks in advance...


Dale.



------------------------------------------------------------------------
Dale Stanbrough			|
Phillip Institute of Technology	|
Melbourne, Australia		|
				|
dale@phillip.edu.au		|
				

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1991-07-12 22:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-07-12 22:17 Discriminants & limited privates - yuk? munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!phillip.edu.au!x01233

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox