comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <see.reply.to@maps.futureapps.de>
Subject: Programmer controlled object creation (was: Re: Ada OS based on Minix3)
Date: Sat, 15 Nov 2008 12:57:12 +0100
Date: 2008-11-15T12:57:13+01:00	[thread overview]
Message-ID: <491eb919$0$31346$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <j5949itkj2fy$.xhhf37n829u7$.dlg@40tude.net>

Dmitry A. Kazakov wrote:
> On Fri, 14 Nov 2008 18:11:34 -0500, Robert A Duff wrote:
> 
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>
>>> On Tue, 11 Nov 2008 17:09:54 -0500, Robert A Duff wrote:
>>>> Initialization: Use function calls.  They work for all types.
>>>> I think we've discussed this idea before, but I don't remember
>>>> any fundamental problems.
>>> The fundamental problem is that a constructor cannot be decomposed into
>>> functions. In the function body you have to construct the object before you
>>> return it. Who does it and what?
>> In Ada 2005, a constructor function creates the object via another
>> function call, or via an aggregate, or via an uninitialized
>> variable (to which it assigns components).
> 
> Here we are. At the end of this chain there is always some magical
> construct which is not a function. It is the construct which yields the
> object of the type. The object is *already* constructed at this point, per
> magic, not per function which is not yet even returned.

So what would programmer controlled object creation
look like?  I'm assuming you want the compiler to check
that usual Ada semantics is still intact. That is, all decisions about
size, alignment, placement, etc.

There be partial construction, IIUC? That is, some components
may be constructed late: Another function gets the partially
constructed object?  That is,

    function Make_Pizza (Hunger: Size) return Pizza;
      pragma Convention (Constructor, Make_Pizza);

    procedure Add_Topping (Object: in out Pizza; ...);
       -- creates a Topping component and fills it
       pragma Convention (Constructor, Add_Topping);

    type Pizza is tagged
       record
          Dough: Positive range 200 .. 1_000;
          Topping: ...;
        end record;

    function Make_Pizza (Hunger: Size) return Pizza is
    begin
       return Result: Pizza do
          -- we would NOT have an Object yet

          Pizza'Constructor(Dough => Grams (Hunger));
          --  we may NOT have a Topping component yet

          Add_Topping(Result);
             -- pass partial object (or info about it?)

          -- now we have a Topping component
       end return;
    end Make_Pizza;



  reply	other threads:[~2008-11-15 11:57 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-07 14:10 Ada OS based on Minix3 Cedric.Lannock
2008-11-07 16:20 ` xavier grave
2008-11-08  3:46 ` anon
2008-11-10  8:12 ` Ivan Levashew
2008-11-10  8:58   ` Dmitry A. Kazakov
2008-11-10  9:26     ` Ivan Levashew
2008-11-10 10:11     ` Georg Bauhaus
2008-11-10 10:24     ` Jacob Sparre Andersen
2008-11-10 10:51       ` Dmitry A. Kazakov
2008-11-10 11:07         ` Ludovic Brenta
2008-11-10 11:42           ` Ivan Levashew
2008-11-10 12:04             ` Ludovic Brenta
2008-11-11 22:16           ` Robert A Duff
2008-11-12  6:28             ` Ivan Levashew
2008-11-10 10:50     ` Ivan Levashew
2008-11-10 11:01       ` Dmitry A. Kazakov
2008-11-10 15:31         ` Robert A Duff
2008-11-10 15:56           ` Dmitry A. Kazakov
2008-11-11 22:09             ` Robert A Duff
2008-11-12  9:47               ` Dmitry A. Kazakov
2008-11-13  0:58                 ` Randy Brukardt
2008-11-13 17:28                   ` Dmitry A. Kazakov
2008-11-13 23:25                     ` Randy Brukardt
2008-11-14  9:30                       ` Dmitry A. Kazakov
2008-11-14 23:11                 ` Robert A Duff
2008-11-15 10:04                   ` Dmitry A. Kazakov
2008-11-15 11:57                     ` Georg Bauhaus [this message]
2008-11-15 12:44                       ` Programmer controlled object creation Dmitry A. Kazakov
2008-11-10 10:18   ` Ada OS based on Minix3 Georg Bauhaus
2008-11-11  1:00 ` Freejack
2008-11-11  8:32 ` Martin Krischik
2008-11-11 11:09   ` Peter C. Chapin
2008-11-11 11:59     ` Georg Bauhaus
2008-11-11 14:35       ` Ludovic Brenta
2008-11-11 16:49         ` Georg Bauhaus
2008-11-13  7:10         ` Martin Krischik
2008-11-13  7:01       ` Martin Krischik
2008-11-13  6:48     ` Martin Krischik
2008-11-13  8:09       ` Thomas Locke
2008-11-13 10:16         ` Alex R. Mosteo
replies disabled

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