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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e859f774bbb3dfb3 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeedt0.toon.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: another way to shoot yourself in the foot? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <54157920-377a-441b-9b0b-f0c4f9ddffec@f36g2000hsa.googlegroups.com> <54435596-5e7f-4686-a2b7-1e22d7c4b186@p25g2000hsf.googlegroups.com> <483ugmvkl2ea.1hrqsq7ru4t1x$.dlg@40tude.net> <12dhu8e1w5ac9.1s9hzkf9d2rsy$.dlg@40tude.net> <3bc1018b-b275-4a59-8302-6a3262766f63@z24g2000prf.googlegroups.com> <6ug5vhz5j1e4$.1lqpd52jz6qry.dlg@40tude.net> <1s88o46xl9o9b$.1e88zxl9es93z$.dlg@40tude.net> <486184b7$0$6615$9b4e6d93@newsspool2.arcor-online.net> <1ilzy5ufjyn6p$.cu5078bqe0mj$.dlg@40tude.net> <48621ea8$0$6556$9b4e6d93@newsspool3.arcor-online.net> Date: Wed, 25 Jun 2008 14:06:44 +0200 Message-ID: <1oxofpm1t6b0n$.172x1c1i5mx9p.dlg@40tude.net> NNTP-Posting-Date: 25 Jun 2008 14:06:44 CEST NNTP-Posting-Host: f5c5ff41.newsspool3.arcor-online.net X-Trace: DXC=6WQ7enW;^6ZC`4IXm65S@:3>?WO6Tg=YTh73 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:869 Date: 2008-06-25T14:06:44+02:00 List-Id: On Wed, 25 Jun 2008 12:32:05 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov schrieb: > >>> And now automatic operations like Initialize and Finalize, >>> hooked on a single type (and possibly discriminants---does >>> GNAT like at last :-) are supposed to be the solution of >>> all data management? >> >> Yes they are. Note that constructing/destructing hooks have different rules >> of composition, like aggregates and assignments have. They are not >> overridden they are extended. (Ada's Finalization is bogus, alas). > > Just one point ad hoc. > Taking the notion of construction further, define the concept > of initialization. > > In general, initialization of an object Obj_1 of type T1 > may logically be related to the observable state of Obj_2 > of type T2, where observable state means result of operations > or (component) values. As these states change while a > program is running, the dependences may not always be the same. > > Obj_1's initialization may logically depend on > > F(Obj_1, ..., Obj_N), > > or more generally on > > F(G_1(Obj_1_1, ..., Obj_M_1), ... G_J(Obj_1_J, ..., Obj_M_J)). > > for some finite sets of objects and functions. > Basically, on anything that can be programmed into an expression > used for initializing. It may be cross unit, involve P98.T19 or not, > or A.B.T42 only if G_17(Obj_127) > 666 etc. > > This "net of dependence" would mean that a constructor will have > to adjust its behavior to the current state of the program. Adjustment > may be realized through dispatching to a load of objects, other > constructors, etc. etc. etc. IOW, every constructor becomes a huge > factory in disguise. It has to perform case distinction. > How is this seemingly special construction different from just > normal programming? The only added value of constructors that > I can see is that I can point to a few functions which "point to" > all this. A good addition, and not a small one. But should we > therefore abandon all other means of initializing things? > > If construction turns out to be mostly normal programming, why > not use plain old language features in addition to specialized > constructor programming? For example, use local scopes and > visibility for providing (computed) initial values, even though > a scope is not an operation of a type, like a construtor function > is. Because of. Information hiding. You want to promote the object as an opaque abstract type. It is the type which is responsible for object construction. It is just not the user's business. This is a pragmatic argument of avoiding a huge distributed overhead of proper initialization of all instances the given type might ever have. It is a maintenance disaster if something gets changed. The theoretical argument is that initialization is not equivalent to construction. Well, it is, when types are ignored. But types does not exist at run-time anyway. Type is an abstraction used to annotate untyped machine code. So while the machine code might appear same, semantically it is different [*]. Now, within a typed framework, the constructor cannot be decomposed into subprograms, it fundamentally cannot. There is no way to convert raw junk of bits into the same bits having the meaning of an object of the given type. ------------ * The simplest way to illustrate this in Ada is: type Int is new Integer; -- The code will be same -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de