comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <no.spam@no.spam.com>
Subject: Re: Limited_Controlled and constructor functions
Date: Fri, 19 Jan 2007 08:58:54 +0100
Date: 2007-01-19T08:58:54+01:00	[thread overview]
Message-ID: <eoptnu$62f$1@cernne03.cern.ch> (raw)
In-Reply-To: <wcc3b6870ei.fsf@shell01.TheWorld.com>

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/



  reply	other threads:[~2007-01-19  7:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18  9:51 Limited_Controlled and constructor functions Maciej Sobczak
2007-01-18 12:13 ` AW: " Grein, Christoph (Fa. ESG)
2007-01-18 16:41 ` Robert A Duff
2007-01-19  7:58   ` Maciej Sobczak [this message]
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