From: Robert A Duff <bobduff@TheWorld.com>
Subject: Re: I am not understanding user defined exceptions
Date: Thu, 09 Feb 2017 14:08:11 -0500
Date: 2017-02-09T14:08:11-05:00 [thread overview]
Message-ID: <wcco9ybfahw.fsf@TheWorld.com> (raw)
In-Reply-To: o7ga31$6a9$1@franka.jacob-sparre.dk
"Randy Brukardt" <randy@rrsoftware.com> writes:
> The GNAT approach causes a very significant maintenance hazard: if you
> depend on the static properties of a predicate, a seemingly innocous change
> can break a lot of code. (And that code may not even be yours, if the
> predicate is in a specification of a shared library. Imagine someone
> changing a predicate in the specifications of GDKAda that changes it from
> static to dynamic; a lot of other people's code would break ...
I don't buy it (as you may remember, because I said so in an ARG
meeting). The reason is that all these horrible things you mention
can happen when you change a static predicate to a different static
predicate. E.g.:
subtype S is Integer with Static_Predicate => S >= 0;
If you change it to:
subtype S is Integer with Static_Predicate => S >= 1;
client code is just as likely to break as if you changed it
to a dynamic predicate. So what? Any time you change the
visible part of a widely used library unit, you have to be
careful about breaking clients.
Note that the first S above is exactly the same as:
subtype S is Integer range 0 .. Integer'Last;
And we don't bother to mark that as a static range.
You could change it to "0 .. Dynamic_Value", and break
clients.
>...and they'd have
> no understanding of why (or any hope of fixing it).
Now that's REALLY overstating the case. Anybody who can read Ada code
can understand why (and hope to fix it).
>... By declaring your intent
> as static or dynamic, clients can properly use the predicate subtype and you
> as the maintainer can't break their expectations without at least realizing
> that there is a potential problem.
The above argument proves that to be wrong -- the maintainer CAN
break clients DESPITE the fact that the predicate is marked
Static_.
> This is especially true as many expressions that *seem* simple aren't
> allowed as static predicates (simple math operators aren't allowed, for
> instance). After all, a static predicate is a (bizarre) way to describe a
> set constraint, whereas a dynamic predicate is an implicitly inserted
> assertion. Quite different semantically.
In the same sense that a static constant is quite different from a
dynamic one. For example you can say "when X =>" in a case
statement if X is static. And if somebody changes X to a different
static value, or to a dynamic value, the case statement will
become illegal.
- Bob
next prev parent reply other threads:[~2017-02-09 19:08 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 20:27 I am not understanding user defined exceptions patrick
2017-02-03 21:08 ` Randy Brukardt
2017-02-03 22:41 ` patrick
2017-02-04 1:26 ` Dennis Lee Bieber
2017-02-04 6:58 ` J-P. Rosen
2017-02-04 17:08 ` Simon Wright
2017-02-08 17:55 ` Georg Bauhaus
2017-02-08 23:37 ` Randy Brukardt
2017-02-09 19:08 ` Robert A Duff [this message]
2017-02-09 21:47 ` Randy Brukardt
2017-02-09 22:52 ` Robert A Duff
2017-02-10 9:52 ` Simon Wright
2017-02-10 10:11 ` Dmitry A. Kazakov
2017-02-10 20:56 ` Randy Brukardt
2017-02-10 21:09 ` Randy Brukardt
2017-02-10 22:07 ` Dmitry A. Kazakov
2017-02-13 23:20 ` Randy Brukardt
2017-02-14 8:39 ` Dmitry A. Kazakov
2017-02-14 20:07 ` Randy Brukardt
2017-02-15 9:32 ` Dmitry A. Kazakov
2017-02-10 23:53 ` Shark8
2017-02-09 0:36 ` Robert A Duff
2017-02-09 7:43 ` Simon Wright
2017-02-09 19:15 ` Robert A Duff
2017-02-09 20:39 ` Randy Brukardt
2017-02-09 21:06 ` Randy Brukardt
2017-02-09 23:08 ` Robert A Duff
2017-02-04 8:41 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox