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.5 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,TO_NO_BRKTS_PCNT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,31465939d9bd22cc,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!novia!transit3.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Message-Id: <4be20f28$0$2431$4d3efbfe@news.sover.net> From: "Peter C. Chapin" Subject: Question about default discriminants and mutable objects. Newsgroups: comp.lang.ada Date: Wed, 05 May 2010 20:41:57 -0400 User-Agent: KNode/0.10.9 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Organization: SoVerNet (sover.net) NNTP-Posting-Host: 904aa2e9.news.sover.net X-Trace: DXC=B^KWUn1^MWO67Vhm@iLL[O X-Complaints-To: abuse@sover.net Xref: g2news2.google.com comp.lang.ada:11320 Date: 2010-05-05T20:41:57-04:00 List-Id: Hopefully I can ask this question clearly... I understand that an instance of a type with default discriminants can be mutated (here I mean have its discriminant changed) via assignment. It seems like the most effective way for a compiler to support that ability is to always allocate enough memory for the object to account for all possible discriminant values. Mordechai Ben-Ari pretty much says this explicitly in his book "Ada for Software Engineers." I also understand that an instance of a type without default discriminants can't be mutated in this way (that is, by assignment). If a new value is assigned to the object with the wrong discriminant the result is Constraint_Error. This would allow the compiler to allocate just the memory necessary for that particular discriminant value used to initialize the object since there would never be a (successful) attempt to stuff a larger object into that space. It seems like conceptually the issue of default discriminants and mutability (in the sense I mean here) are independent. 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. Furthermore one could imagine treating default discriminants as 100% syntactic sugar and not endowing them with any special semantics regarding mutability. Okay, so my question is: what was the rationale behind combining the notion of default discriminants with the notion of mutability? Is there some subtle technical reason why they must go together? I don't have pressing need to know... I'm curious and I'm trying to deepen my understanding of this topic. Thanks! Peter