comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Task components, the rationale
Date: Thu, 14 Jul 2011 10:52:59 +0200
Date: 2011-07-14T10:53:00+02:00	[thread overview]
Message-ID: <4e1eae6c$0$6570$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <d85499cd-83f1-4bd7-a74c-7e21b9aba550@z39g2000yqz.googlegroups.com>

On 7/13/11 10:58 PM, Maciej Sobczak wrote:
> On Jul 13, 8:52 pm, "Dmitry A. Kazakov"<mail...@dmitry-kazakov.de>

>> There is no simple solution for this.
>
> You have to just, you know, simply, introduce constructors to the
> language. This is my pet feature for Ada 2020. :-)

Out of curiosity, would this be enough?  How will it work?
Assuming, naively, not knowing C++, that constructors of C++
could lead the way,   I get

#include <iostream>

namespace
{
   class Outer;

   class Inner {
   private:
     Outer* shell;
   public:
     Inner(Outer*);
   };

   class Outer {
   private:
     Inner i;
   public:
     int some_value;
     Outer();
   };

   Inner::Inner(Outer* wrap) {
     this->shell = wrap;
     std::cout << "initializing inner, this->shell->some_value = "
               << this->shell->some_value << std::endl;
   }

   Outer::Outer() : i(this) {
     this->some_value = 123;
     std::cout << "initialized outer, this->some_value = "
               << this->some_value << std::endl;
   }
}

int main()
{
   Outer x;

   return 0;
}


$ c++ news23.cpp
$ ./a.out
initializing inner, this->shell->some_value = 1606422610
initialized outer, this->some_value = 123
$



  reply	other threads:[~2011-07-14  8:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13 18:52 Task components, the rationale Dmitry A. Kazakov
2011-07-13 20:58 ` Maciej Sobczak
2011-07-14  8:52   ` Georg Bauhaus [this message]
2011-07-14 18:15     ` Maciej Sobczak
2011-07-22 23:28       ` Randy Brukardt
2011-07-14  9:23   ` Dmitry A. Kazakov
replies disabled

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