From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,27dc164946031512,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news.glorb.com!newsfeed-0.progon.net!progon.net!news-zh.switch.ch!switch.ch!cernne03.cern.ch!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Limited_Controlled and constructor functions Date: Thu, 18 Jan 2007 10:51:02 +0100 Organization: CERN News Message-ID: NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Trace: cernne03.cern.ch 1169113863 7222 137.138.37.241 (18 Jan 2007 09:51:03 GMT) X-Complaints-To: news@@cern.ch NNTP-Posting-Date: Thu, 18 Jan 2007 09:51:03 +0000 (UTC) User-Agent: Thunderbird 1.5.0.9 (X11/20061220) Xref: g2news2.google.com comp.lang.ada:8249 Date: 2007-01-18T10:51:02+01:00 List-Id: 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/