From: Maciej Sobczak <no.spam@no.spam.com>
Subject: Limited_Controlled and constructor functions
Date: Thu, 18 Jan 2007 10:51:02 +0100
Date: 2007-01-18T10:51:02+01:00 [thread overview]
Message-ID: <eonfu7$71m$1@cernne03.cern.ch> (raw)
Hi,
Consider another Limited_Controlled problem:
-- p.ads:
with Ada.Finalization;
package P is
type T (<>) is private;
function Constructor(I : Integer) return T;
private
type Array_Of_Ints is array (Positive range <>) of Integer;
type T (Size : Positive) is new Ada.Finalization.Controlled with
record
A : Array_Of_Ints(1..Size);
end record;
end P;
-- p.adb:
package body P is
function Constructor(I : Integer) return T is
begin
return T'(Ada.Finalization.Controlled with
Size => 1, A => (1 => I));
end Constructor;
end P;
It looks a bit convoluted. :-)
The idea is to have a T type that contains the array of integers and a
constructor function that creates T with single element in the contained
array. T is private, controlled and indefinite, to force the use of
constructor function whenever T is declared.
Now, I want to make it limited as well by adding limited before private
and changing Controlled to Limited_Controlled in two places.
I get this when compiling the package:
cannot return a local value by reference
"Program_Error" will be raised at run time
What's going on?
--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
next reply other threads:[~2007-01-18 9:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-18 9:51 Maciej Sobczak [this message]
2007-01-18 12:13 ` AW: Limited_Controlled and constructor functions Grein, Christoph (Fa. ESG)
2007-01-18 16:41 ` Robert A Duff
2007-01-19 7:58 ` Maciej Sobczak
2007-01-19 9:41 ` Dmitry A. Kazakov
2007-01-19 13:45 ` Maciej Sobczak
2007-01-19 14:33 ` Dmitry A. Kazakov
2007-01-22 8:59 ` Maciej Sobczak
2007-01-20 17:09 ` Gautier
2007-01-20 19:39 ` Gautier
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox