comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Differences between Ada 83 and other revisions
Date: Fri, 14 Feb 2014 09:08:50 -0500
Date: 2014-02-14T09:08:50-05:00	[thread overview]
Message-ID: <wcceh353hxp.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 6aca36a4-cd78-4098-a1f7-646cb37cd14d@googlegroups.com

adambeneschan@gmail.com writes:

> The one new feature that I think *could* be used to create less
> reliable code, if abused, is 'Unchecked_Access.

Well, I think you have to look at the alternatives, rather than
looking at a feature like 'Unchecked_Access in isolation.

Suppose you have an Ada 2012 (or 2005 or 95) program that uses
'Unchecked_Access.  There is a risk of dangling pointers.

But how would you write that code in Ada 83?  Probably you'd
allocate an object on the heap.  And Ada 83 didn't have finalization,
so you have to manage deallocation by hand.  So in Ada 83 you would
have a similar risk of dangling pointers, plus additional risks:
storage leaks, heap fragmentation, etc.

Or perhaps (still talking about Ada 83), you'd use 'Address and
Unchecked_Conversion.  Again, additional risks, such as nonportability
(given that the semantics of 'Address are rather ill defined).
Plus there's no "aliased" there warning you about aliasing.

So although 'Unchecked_Access is indeed an unsafe feature, the
existence of 'Unchecked_Access makes the language safer overall.

I think the same can be said of other supposedly-unsafe features
added to Ada since Ada 83, such as storage pools.

Or consider the assertion facilities ("contracts"): pre/postconditions,
predicates, invariants.  There is a risk that those will raise
an exception and crash the program.  Yet programming using contracts
is clearly safer than the Ada 83 alternatives.

- Bob


  parent reply	other threads:[~2014-02-14 14:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 15:59 Differences between Ada 83 and other revisions yoursurrogategod
2014-02-13 16:12 ` adambeneschan
2014-02-13 18:00   ` yoursurrogategod
2014-02-13 18:07 ` AdaMagica
2014-02-13 19:44 ` Niklas Holsti
2014-02-13 21:25   ` yoursurrogategod
2014-02-13 22:00     ` Niklas Holsti
2014-02-13 22:18       ` adambeneschan
2014-02-14 13:18         ` yoursurrogategod
2014-02-14 13:53           ` AdaMagica
2014-02-14 14:06           ` Jacob Sparre Andersen
2014-02-14 16:47           ` adambeneschan
2014-02-14 14:08         ` Robert A Duff [this message]
2014-02-16  9:36         ` Martin
2014-02-16 14:13           ` Robert A Duff
2014-02-16 15:58             ` J-P. Rosen
2014-02-19 22:09               ` Robert A Duff
2014-02-19 22:23                 ` J-P. Rosen
2014-02-19 22:37                   ` Robert A Duff
2014-04-19  8:59                     ` Jacob Sparre Andersen
2014-02-19 22:34                 ` adambeneschan
2014-02-19 22:58                   ` Robert A Duff
2014-02-13 21:28 ` yoursurrogategod
2014-02-13 23:31   ` Randy Brukardt
2014-02-20 10:30     ` john
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox