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-Thread: a07f3367d7,31465939d9bd22cc X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Question about default discriminants and mutable objects. Date: Wed, 5 May 2010 20:26:48 -0500 Organization: Jacob Sparre Andersen Message-ID: References: <4be20f28$0$2431$4d3efbfe@news.sover.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1273109210 18917 69.95.181.76 (6 May 2010 01:26:50 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 6 May 2010 01:26:50 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news2.google.com comp.lang.ada:11321 Date: 2010-05-05T20:26:48-05:00 List-Id: "Peter C. Chapin" wrote in message news:4be20f28$0$2431$4d3efbfe@news.sover.net... ... > 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. I don't know; I know the idea come from Ada 83, but I have no idea why they chose that. It's been a long-time annoyance in Ada that these two concepts are intertwined. (It's very much like the annoying requirement that a protected function do only read-only things to the protected object, while a protected procedure has to be assumed to modify the protected object (neither are true in general, of course).) > 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 personally think it was a mistake that this implementation was allowed, since it makes many useful discriminated types impossible or excessively expensive in space. Janus/Ada allocates discriminant-dependent components to size, and thus reallocates the components if a discriminant is changed. That of course has other problems (mostly in overhead if the objects are assigned often). Most everyone disagrees with my position on this, the reasoning being that the extra memory allocation overhead isn't justified on real-time systems. Probably there is some happy medium using a combination of both implementations (clearly some real-time systems couldn't allow a reallocating implementation, but that is what we have pragma Restrictions for; for other uses, a more flexible implementation is better, IMHO). Randy.