Re: Dijkstra's guarded commands
- From: anton@xxxxxxxxxxxxxxxxxxxxxxxxxx (Anton Ertl)
- Date: Wed, 03 Dec 2008 15:25:09 GMT
Andrew Haley <andrew29@xxxxxxxxxxxxxxxxxxxxxxx> writes:
Anton Ertl <anton@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Andrew Haley <andrew29@xxxxxxxxxxxxxxxxxxxxxxx> writes:
Generating randomness at runtime where none is needed is surely
inefficient. It can't possibly make any difference to the correctness
of a program, so why do it?
Well, doing a deterministic implementation might turn incorrect
(according to the specification) programs into programs that behave
correctly, whereas this is more unlikely with a random
implementation.
I don't accept that. Here's another incorrect program:
i := 0; j = 0
do
i = 0 -> j := j + 1
| j = 0 -> i := i + 1
od
On a system that used randomness at runtime, this incorrect program
would eventually terminate. I don't think that randomness making a
program appear to work is necessarily more likely than randomness
making a program fail.
In my experience, failing to make progress is a rare bug, and it
usually also shows up in incorrect behaviour in other respects (so the
usual errors of this kind would be visible even with a randomizing
implementation).
OTOH, having a mistake in the rest of the action logic or in the
selection logic is relatively frequent, and if it shows up only in
corner cases, it can stay in programs for a long time, especially if
the corner case can never be excercised because a conditional prevents
it.
That's why I believe that determinism is more likely to cover up such
issues than randomness. OTOH, if we then make that determinism part
of the specification, the program is no longer incorrect, and the
language is better testable.
Of course, Dijkstra's idea of programming (at least later in his life)
was to write the program on paper and prove it correct before ever
letting it run on a computer.
For this approach, the actual implementation is irrelevant, and the
non-deterministic specification is nicer than, e.g., the deterministic
one outlined above, because then one only has to deal with one branch
at a time. In contrast, with a deterministic order, programs are
correct that would otherwise be incorrect, and proving them correct
then requires to look at the combination of conditions when dealing
with a particular branch.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
.
- Follow-Ups:
- Re: Dijkstra's guarded commands
- From: Anton Ertl
- Re: Dijkstra's guarded commands
- From: Andrew Haley
- Re: Dijkstra's guarded commands
- References:
- Re: Dijkstra's guarded commands
- From: Andrew Haley
- Re: Dijkstra's guarded commands
- From: Gerry
- Re: Dijkstra's guarded commands
- From: Andrew Haley
- Re: Dijkstra's guarded commands
- From: Anton Ertl
- Re: Dijkstra's guarded commands
- From: Andrew Haley
- Re: Dijkstra's guarded commands
- Prev by Date: Re: Is there a Forth-pedia ?
- Next by Date: Re: Dijkstra's guarded commands
- Previous by thread: Re: Dijkstra's guarded commands
- Next by thread: Re: Dijkstra's guarded commands
- Index(es):
Relevant Pages
|