* Re: Using discriminant record: problem with assigning to an array in body of case
[not found] <976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com>
@ 2009-03-17 20:05 ` (see below)
2009-03-17 20:24 ` Using discriminant record: problem with assigning to an array in body anon
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: (see below) @ 2009-03-17 20:05 UTC (permalink / raw)
On 17/03/2009 19:55, in article
976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com,
"ChristopherL" <clusardi2k@aol.com> wrote:
> The below procedure compiles and links fine,
No, it doesn't. What else have you changed?
> but when I run it I get a
> "discriminant check failed" error message. Can you please modify this
> code so that the array assignment works.
>
> procedure test is
>
> type GOODS_TYPE is ( LIQUID, TEXTILE);
>
> type TYPE_GOODS( GOODS_TYPE_SELECTION : GOODS_TYPE) is
> record
>
> case GOODS_TYPE_SELECTION is
> when LIQUID =>
> ITEM_NAME : is array ( 0..5 ) of float;
>
> when TEXTILE =>
> LENGTH : float;
> WIDTH : float;
> end case;
> end record;
>
> A : TYPE_GOODS( LIQUID );
>
> begin
>
> A := ( GOODS_TYPE_SELECTION => LIQUID,
> ITEM_NAME => (1.0, 1.1, 1.2, 1.3, 1.4,1.5) );
>
> end test;
--
Bill Findlay
<surname><forename> chez blueyonder.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using discriminant record: problem with assigning to an array in body
[not found] <976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com>
2009-03-17 20:05 ` Using discriminant record: problem with assigning to an array in body of case (see below)
@ 2009-03-17 20:24 ` anon
2009-03-17 20:50 ` Using discriminant record: problem with assigning to an array in body of case Jeffrey R. Carter
2009-03-17 21:15 ` Dmitry A. Kazakov
3 siblings, 0 replies; 4+ messages in thread
From: anon @ 2009-03-17 20:24 UTC (permalink / raw)
-- try this one:
--
procedure test is
type GOODS_TYPE is ( LIQUID, TEXTILE);
-- Ada prefers array to be predefined for usage in records
type float_array is array ( 0..5 ) of float;
type TYPE_GOODS( GOODS_TYPE_SELECTION : GOODS_TYPE) is
record
case GOODS_TYPE_SELECTION is
when LIQUID =>
ITEM_NAME : float_array ; -- new type defined and stops compiler errors
when TEXTILE =>
LENGTH : float;
WIDTH : float;
end case;
end record;
A : TYPE_GOODS( LIQUID );
begin
A := ( GOODS_TYPE_SELECTION => LIQUID,
ITEM_NAME => (1.0, 1.1, 1.2, 1.3, 1.4,1.5) );
end test;
In <976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com>, ChristopherL <clusardi2k@aol.com> writes:
>The below procedure compiles and links fine, but when I run it I get a
>"discriminant check failed" error message. Can you please modify this
>code so that the array assignment works.
>
>procedure test is
>
>type GOODS_TYPE is ( LIQUID, TEXTILE);
>
>type TYPE_GOODS( GOODS_TYPE_SELECTION : GOODS_TYPE) is
> record
>
> case GOODS_TYPE_SELECTION is
> when LIQUID =>
> ITEM_NAME : is array ( 0..5 ) of float;
>
> when TEXTILE =>
> LENGTH : float;
> WIDTH : float;
> end case;
> end record;
>
> A : TYPE_GOODS( LIQUID );
>
> begin
>
> A := ( GOODS_TYPE_SELECTION => LIQUID,
> ITEM_NAME => (1.0, 1.1, 1.2, 1.3, 1.4,1.5) );
>
>end test;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using discriminant record: problem with assigning to an array in body of case
[not found] <976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com>
2009-03-17 20:05 ` Using discriminant record: problem with assigning to an array in body of case (see below)
2009-03-17 20:24 ` Using discriminant record: problem with assigning to an array in body anon
@ 2009-03-17 20:50 ` Jeffrey R. Carter
2009-03-17 21:15 ` Dmitry A. Kazakov
3 siblings, 0 replies; 4+ messages in thread
From: Jeffrey R. Carter @ 2009-03-17 20:50 UTC (permalink / raw)
ChristopherL wrote:
> The below procedure compiles and links fine, but when I run it I get a
> "discriminant check failed" error message. Can you please modify this
> code so that the array assignment works.
>
> ITEM_NAME : is array ( 0..5 ) of float;
If this compiles, you have a serious problem in your compiler.
--
Jeff Carter
"My dear Mrs. Hemoglobin, when I first saw you, I
was so enamored with your beauty I ran to the basket,
jumped in, went down to the city, and bought myself a
wedding outfit."
Never Give a Sucker an Even Break
111
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using discriminant record: problem with assigning to an array in body of case
[not found] <976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com>
` (2 preceding siblings ...)
2009-03-17 20:50 ` Using discriminant record: problem with assigning to an array in body of case Jeffrey R. Carter
@ 2009-03-17 21:15 ` Dmitry A. Kazakov
3 siblings, 0 replies; 4+ messages in thread
From: Dmitry A. Kazakov @ 2009-03-17 21:15 UTC (permalink / raw)
On Tue, 17 Mar 2009 12:55:15 -0700 (PDT), ChristopherL wrote:
> The below procedure compiles and links fine, but when I run it I get a
> "discriminant check failed" error message. Can you please modify this
> code so that the array assignment works.
>
> procedure test is
>
> type GOODS_TYPE is ( LIQUID, TEXTILE);
>
> type TYPE_GOODS( GOODS_TYPE_SELECTION : GOODS_TYPE) is
> record
>
> case GOODS_TYPE_SELECTION is
> when LIQUID =>
> ITEM_NAME : is array ( 0..5 ) of float;
This is illegal. Anonymous array type may not appear as a component of a
record declaration.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 4+ messages in thread