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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b5ab7c96b188b59e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-19 03:25:56 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-atanamir.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Redefining := (was: The "()" operator revisited.) Date: Mon, 19 Jan 2004 12:33:02 +0100 Message-ID: References: <4003EEEC.40106@noplace.com> <%1WMb.25$3f4.77748@news20.bellglobal.com> <100gmej9varun91@corp.supernews.com> NNTP-Posting-Host: tar-atanamir.cbb-automation.de (212.79.194.116) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1074511554 18622757 212.79.194.116 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:4549 Date: 2004-01-19T12:33:02+01:00 List-Id: On Fri, 16 Jan 2004 15:37:27 -0600, "Randy Brukardt" wrote: >"Jeffrey Carter" wrote in message >news:ltHNb.11315$1e.3373@newsread2.news.pas.earthlink.net... >> Robert A Duff wrote: >> >> > It has to do with mutable record types (defaulted discrims). >> > That's unfortunate; if you want to redefine ":=" for a non-mutable >> > type, it's pretty annoying to be told you can't do that because >> > mutable types exist in the language. > >Bob's comment is a bit misleading. The problem is that since mutable types >exist in the language, you can't redefine ":=" for any types. That occurs >because of composition issues. You want user-defined ":=" to compose, such >that a larger type containing a component of a type using user-defined ":=" >uses the user-defined ":=". Now, consider: > > type Something ... > procedure ":=" (Target : out Something; Source : in Something); > > type Mutable (B : Boolean := False) is record > case B is > when True => > S : Something; > when False => > C : Character; > end case; > end record; > > A_True : Mutable(True); > A_False : Mutable(False); > > Obj : Mutable; > > Obj := A_True; -- ?? > >How does the predefined ":=" for Mutable work? It needs to call the >user-defined ":=" for component S. But in this example, what do you pass for >the LHS? It doesn't have a component S! Of course, Mutable.":=" is kind of "multiple dispatching". There are four variants of it: case LHS.B is when True => case RHS.B is when True => call to ":=" on Something; when False => finalize Character; call copy-constructor on Something end case; when False => case RHS.B is when True => finalize Something; call copy-constructor on Character when False => call to ":=" on Character; end case; end case; Provided we had proper constructors of course! (:-)) Assignment can always be consistently generated out of assignments of components and destructors/copy-constructors. The reverse is wrong, as your example clearly shows. Even more obvious example: X : constant Something := Initial; -- should the user-defined ":=" be called here? (:-)) -- If, yes then what would be LHS? -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de