comp.lang.ada
 help / color / mirror / Atom feed
From: mockturtle <framefritti@gmail.com>
Subject: Re: I have no idea why this will not compile.
Date: Sun, 1 May 2016 03:10:32 -0700 (PDT)
Date: 2016-05-01T03:10:32-07:00	[thread overview]
Message-ID: <15f01439-2333-4482-a37c-3aeb33102c4d@googlegroups.com> (raw)
In-Reply-To: <f2fb65f9-9ed2-4211-910c-9234f6819151@googlegroups.com>

You already received two answers that help you to solve the problem.  However, depending on your knowledge of Ada, maybe a longer explanation could be useful.

"limited" in Ada is used to mark a type that cannot be copied.  For example, task types are limited (it does not make much sense copying a task), protected objects are limited (what means to copy them is doubtful).  In the case of File_Type I guess they are limited because the file has an "internal state" that could be bring to subtle errors if copied.  (BTW, also in C you never copy a FILE, but a pointer to FILE, never copying the underling structure).

In Ada is not permitted to use a limited type as a component of a *non limited* record, since this would allow you to avoid the original limited restriction (by copying the record you would copy also the limited component).  Because of this, Ada requires that you declare limited any record that has a limited component.

Solutions?  I can think about three solutions:

1.  Make the record limited
2. Use an access to the limited type
3. Move the limited component outside the record

I think that the best solution depends on your specfic case.

Riccardo

  parent reply	other threads:[~2016-05-01 10:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-01  3:22 I have no idea why this will not compile John Smith
2016-05-01  4:07 ` Jeffrey R. Carter
2016-05-01  6:47 ` Georg Bauhaus
2016-05-01 21:52   ` John Smith
2016-05-02  7:36     ` Georg Bauhaus
2016-05-01 10:10 ` mockturtle [this message]
2016-05-01 20:55   ` John Smith
2016-05-01 23:52     ` Jeffrey R. Carter
2016-05-02  1:02     ` Jeremiah
replies disabled

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