From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Introductory Ada Programming Book
Date: Wed, 4 Jan 2017 15:47:03 -0600
Date: 2017-01-04T15:47:03-06:00 [thread overview]
Message-ID: <o4jqgn$er0$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 4c5dfbe4-7987-48d4-8afc-817a8c134095@googlegroups.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2286 bytes --]
"Shark8" <onewingedshark@gmail.com> wrote in message
news:4c5dfbe4-7987-48d4-8afc-817a8c134095@googlegroups.com...
On Wednesday, January 4, 2017 at 6:45:29 AM UTC-7, raph....@gmail.com wrote:
> Le mercredi 4 janvier 2017 13:49:18 UTC+1, Dmitry A. Kazakov a écrit :
>> >
>> > declare
>> > I : Integer := 1; -- OK
>> > J : Integer; -- Error: not initialized
>> > K : Integer := <>; -- OK: uninitialized, I know what I am doing
>> >
>>
>> Or do it Swift's way and use flow analysis to make use of an
>> uninitialized variable
>> a compile time error. Meh. I guess it's complicated enough as it is to
>> implement
>> an Ada compiler :)
>
>Well, there are certain times where you *want*/*need* non-initialized
>variables;
> it's usually at [operating] system-level, but it does exist. (A good
> example would
> me memory-mapped I/O ports, where your 'initialization' would
> automatically
> send something down the I/O port when you might need to send nothing.)
Right. It also might happen if the initialization is very complex and
interrelated with initializing other variables. Forcing an initialization
just to make the compiler happy would be confusing and potentially expensive
(if the item is large).
I agree with Dmitry. Indeed, I tried hard in Ada 2005 to get (<>) to be an
aggregate usable to default initialize for any type, with the intent to
combine that with a restriction to essentially allow projects to change Ada
to the rule Dmitry suggested. Unfortunately, various technical issues with
private types made that much harder than originally thought, and the idea
was dropped late in the Ada 2005 work.
The problem with requiring flow analysis in a language rule is that it
requires lengthy specifications of exactly what flow analysis is required
for this check, assuming that portability between implementations is
important (and that surely is for Ada). Every compiler does some flow
analysis, but each it likely to do it differently, in different compiler
phases, and having program legality be implementation-defined in that way is
a guaranteed way to have code that cannot be moved to a different
implementation. (Exception contracts have a similar problem.)
Randy.
The problem with using
next prev parent reply other threads:[~2017-01-04 21:47 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-31 13:18 Introductory Ada Programming Book Andrew Shvets
2016-12-31 14:26 ` Lucretia
2016-12-31 15:10 ` Dmitry A. Kazakov
2016-12-31 17:14 ` Andrew Shvets
2016-12-31 14:28 ` Lucretia
2016-12-31 14:34 ` Lucretia
2016-12-31 17:22 ` Andrew Shvets
2016-12-31 17:59 ` Gour
2017-01-02 15:56 ` Andrew Shvets
2017-01-02 16:32 ` Gour
2017-01-03 15:31 ` Patrick Noffke
2017-01-03 22:18 ` Andrew Shvets
2017-01-04 1:14 ` Paul Rubin
2017-01-04 3:07 ` Andrew Shvets
2017-01-04 6:46 ` J-P. Rosen
2017-01-04 9:25 ` raph.amiard
2017-01-04 12:40 ` J-P. Rosen
2017-01-04 12:49 ` Dmitry A. Kazakov
2017-01-04 13:45 ` raph.amiard
2017-01-04 14:14 ` Dmitry A. Kazakov
2017-01-04 15:15 ` Simon Wright
2017-01-10 10:02 ` raph.amiard
2017-01-04 15:18 ` Shark8
2017-01-04 21:47 ` Randy Brukardt [this message]
2017-01-05 3:04 ` Shark8
2017-01-05 7:51 ` G.B.
2017-01-04 13:44 ` raph.amiard
2017-01-04 22:08 ` Jeffrey R. Carter
2017-01-04 22:39 ` Niklas Holsti
2017-01-05 0:38 ` G.B.
2017-01-05 23:52 ` Randy Brukardt
2017-01-05 6:36 ` J-P. Rosen
2017-01-05 8:38 ` Simon Wright
2017-01-10 10:13 ` raph.amiard
2017-01-09 22:01 ` Robert Eachus
2017-01-04 23:42 ` Andrew Shvets
2017-01-05 0:47 ` G.B.
2017-01-05 19:01 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox