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: a07f3367d7,dbbbb21ed7f581b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Operation can be dispatching in only one type 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: <025105f2-5571-400e-a66f-ef1c3dc9ef32@g27g2000yqn.googlegroups.com> <1wtsriaxu0s4s$.ikwnnz5teukp$.dlg@40tude.net> <1iipp3bn16fe2.yqa1gz1ru17a$.dlg@40tude.net> <18wh86jvjvoe0.cofxcc8udm6q$.dlg@40tude.net> <53a35ed9-88ac-43dc-b2a2-8d6880802328@j19g2000yqk.googlegroups.com> <4b091fb9$0$6567$9b4e6d93@newsspool4.arcor-online.net> <1w0q3zxzw79pt$.5z0juiky7kfd$.dlg@40tude.net> <0f177771-381e-493b-92bb-28419dfbe4e6@k19g2000yqc.googlegroups.com> <1nbcfi99y0fkg.1h5ox2lj73okx$.dlg@40tude.net> <59acf311-3a4a-4eda-95a3-22272842305e@m16g2000yqc.googlegroups.com> <3pvk14f2iizi$.b3u242o1oqla.dlg@40tude.net> Date: Tue, 1 Dec 2009 10:00:11 +0100 Message-ID: <15b8l0vp8871o.spmxnk82g75r.dlg@40tude.net> NNTP-Posting-Date: 01 Dec 2009 09:59:08 CET NNTP-Posting-Host: 7df8e13f.newsspool2.arcor-online.net X-Trace: DXC=^BgkfUFER>>]E=H1Q9`787A9EHlD;3Yc24Fo<]lROoR18kF7enW;^6ZC`4IXm65S@:3>?NI@mn43_N>: X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8259 Date: 2009-12-01T09:59:08+01:00 List-Id: On Mon, 30 Nov 2009 15:43:21 -0500, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> The word assignment for most people is associated with state change, >> assuming that there was some state before. So >> >> X : T := F (Y); >> >> looks equivalent to >> >> X : T; >> begin >> X := F (Y); >> >> But they are not. > > Right. I think they should be equivalent. My solution is to use > two different symbols for (initial) assignment and (subsequent) > reassignment. But they cannot be, otherwise the semantics of ":=" would depend on the things done before: X : T; begin X := F (Y); -- Initialization X : T; begin X := Z; X := F (Y); -- [Re]assignment This is unacceptable, because it is untyped. The semantics of ":=" must be solely defined by the types and, maybe, be the context (declarative vs. imperative (as it is now). I don't like even the second part. >>... I would prefer proper constructors, e.g. >> >> X : T (Y); -- Y is a constraint of T, parameter of the constructor >> >> I don't like functions returning limited objects. > > I know you don't, but I don't understand why. Because they cannot return anything, so a "return statement" is invented together with an infinite chain of other unholy things bending and twisting otherwise clear and established notions. > Using named functions as constructors has a big advantage -- you can > have more than one, and you can give them meaningful names. > > For example: > > X : Sequence := Empty_Seq; > Y : Sequence := Singleton_Seq (Item => 123); > Z : Sequence := Make_Sequence (Length => 123); > > With discriminants, what does the 123 mean? You have to pick one. No problem: X : Sequence; Y : Sequence (Item => 123); Z : Sequence (Length => 123); In my imaginary world public discriminant (as well as a public record component) is only an interface, therefore it is no problem for a type have any collection of public discriminant sets. They are just like other operations, you could overload them if necessary. >> But there also are two other forms of standard assignments. Depending on >> whether the left part is available: >> >> procedure ":=" (Left : in out T; Right : T); >> >> and >> >> function ":=" (Right : T) return T; >> >> Ada uses the second form, but obviously there are important cases where the >> first form is preferable (and conversely). >> >> And further, there are three variants per each concerning dispatch: >> >> procedure ":=" (Left : in out T; Right : T); -- Full MD >> procedure ":=" (Left : in out T; Right : T'Class); -- Target-controlled >> procedure ":=" (Left : in out T'Class; Right : T); -- Source-controlled >> >> It would be difficult to sort this out! (:-)) > > Yeah, I'm not sure what the right answer is. I think that assignment should be considered a plain primitive procedure with no special treatment. Initialization has in my view nothing to do with it. The language should visually separate both. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de