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,b553d2c02a2df59f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!oleane.net!oleane!nerim.net!proxad.net!proxad.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: limited types (Was: Records that could be arrays) Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.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: <1cwl2r5h594du$.1q4kglbpb2bma.dlg@40tude.net> <10ovc4gxk6wka.gttjb2v0fbcq$.dlg@40tude.net> Date: Mon, 27 Feb 2006 10:11:28 +0100 Message-ID: <13yslifejxwuq.15rip8gh2aufj.dlg@40tude.net> NNTP-Posting-Date: 27 Feb 2006 10:11:28 MET NNTP-Posting-Host: 6aecbd81.newsread4.arcor-online.net X-Trace: DXC=>WPZM_JPn6:E][lTbkER26:ejgIfPPld4jW\KbG]kaM8Qc4L4[MA2T0jn2WFN_6Hh>[6LHn;2LCV>7enW;^6ZC`4IXm65S@:3>? X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:3180 Date: 2006-02-27T10:11:28+01:00 List-Id: On Sun, 26 Feb 2006 22:07:00 GMT, Matthew Heaney wrote: > "Dmitry A. Kazakov" writes: > >> On Sun, 26 Feb 2006 18:20:39 GMT, Matthew Heaney wrote: >>> Huh? An Ada 2005 constructor function *is* a constructor. It's no >>> different from a copy ctor in C++. >> >> No. The constructor is wrapped by the function. Differently to a true >> constructor, you cannot ensure the wrapper will always be called for some >> specified signature. > > This is a specious argument. If you says the "real" constructor is wrapped by > a function then you're guilty of moving the goal-posts. > > We're talking about requiring that a constructor be called. The syntax doesn't > matter. That fact that Ada 2005 spells it f-u-n-c-t-i-o-n is irrelevent. There is a fundamental difference between a subprogram and a constructor. A subprogram can implement a part of a constructor (like Initialize), it can call to a constructor (like Copy), but it cannot *be* a constructor. Constructors are not decomposable into subprograms. Copy is a subprogram as any other. That means, other subprograms can do exactly the same, i.e. you have a backdoor wide open. > If you want to force a constructor to be used, then you can make the partial > view of the type indefinite. It is not a programmer's choice and not a question of view. There should be absolutely no way to pass construction by. >> 3. Containers of specific types building a parallel types hierarchy. I.e. >> if S is a subtype of T, then a container type with the elements of S is a >> subtype of a container type with the elements of T. > > You have totally misunderstood the design of the Ada 2005 container library. > > When you use cursors, then this abstracts-away the container itself, leaving > you with a sequence of elements. This model works for all the containers > already (and for arrays too, in fact). > > Write your algorithms in terms of sequences of elements instead of containers, > and you can forget about containers. No, thanks. If I wished that sort of untyped design, there would be C++ and dynamically typed languages at my disposal. I don't want untyped containers. I would keep boxes for apples and barrels for herrings in separate rooms. >> If the compiler knew that Copy is a constructor it could safely compose it >> out of constructors of the bases and the components (in most of cases.) > > In practice concrete derived classes must implement their own ctors, that call > the ctor of the base class. It must be called automatically, like in C++. It is already so in Ada for the parts generated by the compiler. You cannot override construction of the components. There is no reason to treat user-defined parts otherwise. You can skip Initialize, when you inherit and cannot when you aggregating. Nonsense. > In the case at hand, you need an operation that takes type ET'Class, which is > the type used to instantiate the generic, so you have to write it yourself, the > same as for any other operation. This is an untyped model. As I said, I prefer a contract-based model. If copyable type is the contract, that should require a copy constructor. >> And this is an argument? (:-)) > > This ignores the history of Ada language evolution: > > Ada83: no function pointers; royal pain > Ada95: function pointers at library-level only: GUI callbacks, etc > Ada05: function pointers in nested scopes too > > No one seems to agree with you, Dmitry! The trend has been to allow the > declaration of "ugly" function pointers in more places, not fewer. When Ada 95 added function pointers, it just admitted that functions are regular objects. When Ada 05 allows anonymous access types for functions it only pursues this idea of regularity further. I see no reason how this can contradict to functions as values? Why a function cannot be passed as a normal "in" parameter of limited type? Give me a reason. Why don't we write: "not null access Integer" to pass Integer? Further, considering distributed systems, how to marshal a function to remote node, if functions does not have values? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de