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 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.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: Re: Limited_Controlled and constructor functions Date: Fri, 19 Jan 2007 08:58:54 +0100 Organization: CERN News Message-ID: References: NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: cernne03.cern.ch 1169193534 6223 137.138.37.241 (19 Jan 2007 07:58:54 GMT) X-Complaints-To: news@@cern.ch NNTP-Posting-Date: Fri, 19 Jan 2007 07:58:54 +0000 (UTC) User-Agent: Thunderbird 1.5.0.9 (X11/20061220) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:8312 Date: 2007-01-19T08:58:54+01:00 List-Id: Robert A Duff wrote: > It works in Ada 2005. That's good news. :-) > It's one of my favorite features of Ada 2005. It's one of the many features that are essential for writing robust code, IMHO (from the C++ perspective). > I'm not entirely sure what you're trying to accomplish, since the length > of that array can't change, and there's nothing interesting for Finalize > to do in this example. Maybe you have other constructors? Yes, there are other constructors that accept more parameters and that create longer arrays. What I want to accomplish is the functional way of building lists of values of variant types: P : constant Params := Make_Params(Param("Hello"), Param("Ada"), Param(12), Param(3.14))); Make_Params is a constructor function that creates a list of 4 parameters, each of them being a variant. I wanted to be able to store Strings in the variant without constraining their lengths (which is impossible), so I decided to use access variable that points to unconstrained String. I migh use Unbounded_String as well, but I don't yet see what would be the difference. Everything should be nicely cleaned up after that - that's why Params is controlled, and since I don't want to bother with copy semantics, it is also limited. It is part of the simple database binding that I wanted to write for the sake of exercise. I will make the whole public once it's finished (but I need Ada2005 compiler for that! :-) ). -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/