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,31465939d9bd22cc X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Question about default discriminants and mutable objects. 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: <4be20f28$0$2431$4d3efbfe@news.sover.net> Date: Thu, 6 May 2010 17:15:24 +0200 Message-ID: NNTP-Posting-Date: 06 May 2010 17:15:24 CEST NNTP-Posting-Host: b818452e.newsspool2.arcor-online.net X-Trace: DXC=iPZgk8k1[05_A0jCfgHO6>A9EHlD;3Yc24Fo<]lROoR18kF7enW;^6ZC`4IXm65S@:3>?0JhN1>3JXm1 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:11327 Date: 2010-05-06T17:15:24+02:00 List-Id: On Wed, 05 May 2010 20:41:57 -0400, Peter C. Chapin wrote: > I also understand that an instance of a type without default discriminants > can't be mutated in this way (that is, by assignment). You can assign it as a whole as well as its components individually. The object is mutable, but you cannot change its constraint. Compare it with similar cases:: S : String := "abc"; Here the constraint is the array bounds. They cannot be changed, yet S is mutable. T : Foo'Class := ...; Here the constraint is the type tag. It cannot be changed, but T is mutable. > One could imagine some currently > non-existent syntax that would allow the programmer to mark a type > declaration so that the compiler allowed discriminant values to be changed > via assignment without leaning on the mechanism of default discriminants. That is not a property of the type. It is of a type constraint. Type + constraint = subtype. Ada is a bit sloppy in the object's subtype specification. When you declare S as String you write a type, but the compiler reads it as a constrained subtype of String. That is not good, but it is difficult to propose a cure. Probably: S : String (<>); -- Any subtype of String T : Foo'Class (<>); -- Any type from the class etc. > Furthermore one could imagine treating default discriminants as 100% > syntactic sugar and not endowing them with any special semantics regarding > mutability. IMO, discriminant's defaults should imply nothing like what they do now. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de