From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada 2005 puzzle
Date: Fri, 20 Jul 2012 14:49:14 +0200
Date: 2012-07-20T14:49:14+02:00 [thread overview]
Message-ID: <12fbl1qrjckwi$.xk9v9nzzcj21.dlg@40tude.net> (raw)
In-Reply-To: ef226fe1-fdb6-4830-be61-0ea3c7324b80@googlegroups.com
On Fri, 20 Jul 2012 04:30:27 -0700 (PDT), in comp.lang.ada you wrote:
> W dniu pi�tek, 20 lipca 2012 10:27:15 UTC+2 u�ytkownik Dmitry A. Kazakov napisa�:
>
>> The problem is that a *new* limited object cannot be result of a function,
>> this is conceptually broken.
>
> Yes, we have already concluded long time ago that one of the priorities
> for Ada is to fix the concept of object construction.
we = you and me? I bet 99% of c.l.a still firmly believe that functions
returning limited objects were all OK.
> But in this case I think that Ada has everything that is needed.
On paper. But practically (because the concept is bogus) I suspect that
there is no way to make it working in real-life scenarios. I cannot count
number of cases when I was forced to redesign because of the damn problem.
If Randy himself, who is a compiler designer and language lawyer, gave up,
what would you expect from laymen?
>> The factory of limited objects passed to
>> Insert must provide means to:
>>
>> 1. determine the constraints of the object (using some set of arguments);
>
> This is not the container's business and will usually come with the
> factory itself - or from the context of the factory. That is why I expect
> this to be used with access to *local* functions, which can drag along all
> the information that is needed to construct the object.
Yes, this one of possible forms of factory.
>> 2. construct the object in place (using the arguments again);
>
> Same as above - the constructor function can bring the "arguments" from
> its surrounding context. You can even create wrappers like this:
>
> procedure Insert_From_Arguments
> (C : in out Container;
> X : in Integer; Y : in Integer; Z : in Integer) is
>
> function Construct return T is
> begin
> return V : T do
> V.X := X; -- constructing T from arguments X, Y, Z
> -- ...
> end return;
> end Construct;
> begin
> C.Insert (Construct'Access);
> end Insert_From_Arguments;
>
> Above, the arguments are passed as part of the Construct's environment.
>
>> 3. optionally, construct the class-wide object upon the specific object
>> (using the arguments)
>
> I expect that class-wide is what the container sees (for example, by being
> instantiated with such a type) - the rest happens the usual way, by
> initializing the class-wide placeholder with specific constructed object.
> This way you could naturally have a container of OO objects.
I meant here a different thing. If you have some dispatching operations to
be performed upon initialization, these must be called on the class-wide
instances, when all ancestors are already initialized.
Let you have a hierarchy of types T1:>T2:>T3. Then construction should run
as follows:
stage 1
T1 constraints evaluation
T2 constraints
T3 constraints
allocation
stage 2
T1 initialization
T2 initialization
T3 initialization
stage 3
T1'Class initialization, only here we could dispatch on T1'Class
T2'Class initialization
T3'Class initialization
>> 1-3 cannot be effectively fused into single operation
>
> Why? What's wrong (ie. what is ineffective) with the above?
ARG tried and failed.
The technical reason IMO is that steps 1,2,3 are intermixed. This prevents
encapsulation of T1/1 + T1/2 + T1/3 into single subprogram. Furthermore at
the stage 1 there is no any object allocated. It cannot be an argument.
Stage 2 needs a type-specific argument. Stage 3 needs a class-wide
argument.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2012-07-26 14:58 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-12 12:54 Ada 2005 puzzle Dmitry A. Kazakov
2012-07-12 15:48 ` Adam Beneschan
2012-07-12 16:34 ` Dmitry A. Kazakov
2012-07-19 6:53 ` Randy Brukardt
2012-07-19 7:55 ` Dmitry A. Kazakov
2012-07-20 2:22 ` Randy Brukardt
2012-07-20 7:20 ` Dmitry A. Kazakov
2012-07-21 0:04 ` Randy Brukardt
2012-07-21 8:34 ` Dmitry A. Kazakov
2012-07-24 2:38 ` Randy Brukardt
2012-07-24 4:23 ` Adam Beneschan
2012-07-24 7:54 ` Dmitry A. Kazakov
2012-07-25 23:39 ` Randy Brukardt
2012-07-26 7:41 ` Dmitry A. Kazakov
2012-07-26 13:08 ` Simon Wright
2012-07-26 13:55 ` Dmitry A. Kazakov
2012-07-27 9:42 ` AdaMagica
2012-07-27 10:32 ` Dmitry A. Kazakov
2012-07-27 11:58 ` Georg Bauhaus
2012-07-27 13:04 ` Dmitry A. Kazakov
2012-07-28 9:48 ` AdaMagica
2012-07-28 10:37 ` Dmitry A. Kazakov
2012-07-28 16:59 ` AdaMagica
2012-07-28 18:21 ` Dmitry A. Kazakov
2012-07-19 8:04 ` Maciej Sobczak
[not found] ` <juaghb$fv9$1@munin.nbi.dk>
2012-07-20 7:30 ` Dmitry A. Kazakov
2012-07-21 17:21 ` Vasiliy Molostov
2012-07-21 19:03 ` Dmitry A. Kazakov
2012-07-21 19:37 ` Vasiliy Molostov
2012-07-21 20:23 ` Dmitry A. Kazakov
2012-07-21 20:53 ` Vasiliy Molostov
2012-07-22 7:41 ` Dmitry A. Kazakov
2012-07-22 8:00 ` Vasiliy Molostov
2012-07-22 8:19 ` Dmitry A. Kazakov
2012-07-22 9:06 ` Vasiliy Molostov
2012-07-22 9:34 ` Dmitry A. Kazakov
2012-07-20 8:09 ` Maciej Sobczak
2012-07-20 8:27 ` Dmitry A. Kazakov
2012-07-20 11:30 ` Maciej Sobczak
2012-07-20 12:49 ` Dmitry A. Kazakov [this message]
2012-07-21 22:46 ` Maciej Sobczak
2012-07-22 8:03 ` Dmitry A. Kazakov
2012-07-22 10:08 ` Florian Weimer
2012-07-22 11:18 ` Dmitry A. Kazakov
2012-07-21 0:12 ` Randy Brukardt
2012-07-22 9:52 ` Florian Weimer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox