comp.lang.ada
 help / color / mirror / Atom feed
From: "Vincent Smeets" <No.Spam@T-Online.de>
Subject: Re: discriminant in constraint must appear alone
Date: Wed, 3 Dec 2003 22:02:52 +0100
Date: 2003-12-03T22:02:52+01:00	[thread overview]
Message-ID: <bqlj28$erv$07$1@news.t-online.com> (raw)
In-Reply-To: bqiq1m$uis$00$1@news.t-online.com

Thanks for your answers,

After evaluating the possibilities, I wil stick to:
    B : String (1 .. D);
and waist memory and having no constraint check. I am using it in a smal
program which I am writing. I can control my self in not violating the
constraints.

Giving the record two discreminants isn't nice for general use because
there needs to be a lot of comments describing the relation between the
discreminants. The type needs to be controled type to implement the
checking between the discreminants. The checking will be done at
run-time, not at compile-time.

Defining the type as a controlled type and using dynamic allocation for
the arrays is too mush overhead for my problem.

The best solution would be a change in the language. Is there something
foreseen for the new version of Ada?

Thanks,
Vincent Smeets


"Vincent Smeets" <No.Spam@T-Online.de> schrieb im Newsbeitrag
news:bqiq1m$uis$00$1@news.t-online.com...
Hallo,

I want to define a discriminated record type with two arrays. One array
only half the size of the other. Below is the type definition that I
want to use.

   type R (D : Positive) is
      record
         A : String (1 .. D);
         B : String (1 .. D / 2);
      end record;

This type definition can't be compiled by the GNAT compiler. It gives
the error message
    "discriminant in constraint must appear alone"
for the record component B. I know this isn't correct Ada, but how
should I define the type in a correct way?

I have defined B as
    B : String (1 .. D);
and only used the first half of it, but this way I waist memory and
can't have any Ada constraint checks for component B. So this is not the
way I want to do it.

Are there other possiblities?


-- 
Thanks,
Vincent Smeets




  parent reply	other threads:[~2003-12-03 21:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-02 19:43 discriminant in constraint must appear alone Vincent Smeets
2003-12-02 20:56 ` Randy Brukardt
2003-12-02 21:15   ` tmoran
2003-12-03  9:06     ` Dmitry A. Kazakov
2003-12-03  0:06 ` Robert I. Eachus
2003-12-03 21:02 ` Vincent Smeets [this message]
2003-12-04 19:16   ` Randy Brukardt
2003-12-05  0:56     ` info version of Ada Reference Manual Stephen Leake
2003-12-05  1:08       ` Stephane Richard
2003-12-05  1:27       ` Ludovic Brenta
2003-12-05  4:36       ` Fionn mac Cuimhaill
2003-12-05  5:28         ` [Totally OT] Nick Roberts
2003-12-05 14:07         ` info version of Ada Reference Manual Stephen Leake
2003-12-05 14:18       ` Arthur Evans Jr
2003-12-05 14:52         ` Stephen Leake
2003-12-07 15:22           ` Arthur Evans Jr
2003-12-05 14:28       ` Georg Bauhaus
replies disabled

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