From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Question about default discriminants and mutable objects.
Date: Wed, 5 May 2010 20:26:48 -0500
Date: 2010-05-05T20:26:48-05:00 [thread overview]
Message-ID: <hrt5sq$if5$1@munin.nbi.dk> (raw)
In-Reply-To: 4be20f28$0$2431$4d3efbfe@news.sover.net
"Peter C. Chapin" <pcc482719@gmail.com> 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.
next prev parent reply other threads:[~2010-05-06 1:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-06 0:41 Question about default discriminants and mutable objects Peter C. Chapin
2010-05-06 1:26 ` Randy Brukardt [this message]
2010-05-06 4:07 ` Gene
2010-05-06 4:56 ` AdaMagica
2010-05-06 14:59 ` Adam Beneschan
2010-05-07 0:47 ` Peter C. Chapin
2010-05-07 2:07 ` Randy Brukardt
2010-05-07 12:35 ` Robert A Duff
2010-05-06 15:15 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox