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-16 13:40:18 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!c03.atl99!sjc70.webusenet.com!news.webusenet.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Redefining := (was: The "()" operator revisited.) Date: Fri, 16 Jan 2004 15:37:27 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <100gmej9varun91@corp.supernews.com> References: <4003EEEC.40106@noplace.com> <%1WMb.25$3f4.77748@news20.bellglobal.com> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:4470 Date: 2004-01-16T15:37:27-06:00 List-Id: "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! In order to deal with this, you pretty much have to separate the finalization and initialization steps. Which is where the current model comes from. An alternative would be to require the ":=" to be overridden for Mutable. But how would the user write that operation? They'd have to have made finalization and initialization operations visible for Something, or it isn't possible. And it seems to eliminate much of the advantage of allowing user-defined versions of these operations (which is automatic composition). (And the requirement probably would be a generic contract model problem. But that's the least of the problems here.) As Bob says, there are things you can't do with Adjust that you'd like to. (It was described as a 75% solution when it was introduced. But our choices were 75% or nothing, given the DRs opposition to anything fancier.) It's hard to imagine doing much better without a lot of incompatibility (you couldn't add a ":=" to an existing type without possibly breaking many uses of the type) and a lot of work. Randy.