FRDB Archives

Freethought & Rationalism Archive

The archives are read only.


Go Back   FRDB Archives > Archives > IIDB ARCHIVE: 200X-2003, PD 2007 > IIDB Philosophical Forums (PRIOR TO JUN-2003)
Welcome, Peter Kirby.
You last visited: Today at 05:55 AM

 
 
Thread Tools Search this Thread
Old 07-17-2003, 12:18 PM   #141
Veteran Member
 
Join Date: Jan 2001
Location: Median strip of DC beltway
Posts: 1,888
Default

Quote:
Originally posted by DNAunion
DNAunion: I was careful to say error, not bug.

The error is that the code uses theList but the subsequent discussion about that code mistakenly refers to it as iList. That error is similar to one I made earlier and was "called on" (my logic was sound, but I accidentally used the wrong name).

ooooohh


You mean people actually read the stuff between the code fragments?
NialScorva is offline  
Old 07-17-2003, 06:24 PM   #142
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

Quote:
NialScorva: ooooohh


You mean people actually read the stuff between the code fragments?
DNAunion: Actually, one can look only at code from the book and there is still an error. Here is a more complete posting.

Quote:
Code:
...
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{
    int arr[] = { 2, 4, 6, 8 };
    list<int> theList;

    for(int k=0; k<4; k++)
        theList.push_back( arr[k] );

    list<int>::iterator iter;

    for(iter = theList.begin(); iter != theList.end(): iter++)
        cout << *iter << ' ';

    cout << endl;
    return 0;
}
...

We define an iterator of type list<int> to match the container type. As with a pointer variable, we must give an iterator a value before using it. In the for loop we initialize it to iList.begin(), the start of the container. ...

An equivalent approach, using a while loop instead of a for loop, might be

Code:
iter = iList.begin();
while( iter != iList.end() )
    cout << *iter++ << ' ';
DNAunion: To which "someone" might reply:

Quote:
[Someone]: No Robert, that code won't work. Can an incompetent programmer like you figure out why?
DNAunion is offline  
Old 07-17-2003, 06:33 PM   #143
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default What up now with EDITs?

DNAunion: Concerning this post here.............never mind.
DNAunion is offline  
Old 07-18-2003, 08:37 AM   #144
Senior Member
 
Join Date: Aug 2002
Location: Florida
Posts: 712
Default Re: Out of Curiosity

Quote:
Originally posted by Deacon Doubtmonger

<.....>
Does anyone know if the specific error in the "killer X-ray machine" software was ever discovered, and could the tenets of program clarity noted here have prevented it?
<.....>

This report published in the IEEE Computer journal says (excerpt):
Quote:
It is clear from the AECL documentation on the modifications that the software allows concurrent access to shared memory, that there is no real synchronization aside from data stored in shared variables, and that the "test" and "set" for such variables are not indivisible operations. Race conditions resulting from this implementation of multitasking played an important part in the accidents.
But the report points out there were factors other than software involved too.

The software deficiency was related to improper synchronization of concurrent processes or threads of execution. This is what makes writing "real time" software hard. My guess is improved program clarity might indirectly have helped by making it easier to spot the errors by maintenance programmers. But still the root problem here was the violation of a basic tenet of concurrent programming: Thou shall protect concurrent access to shared resources (shared variables, data on files, etc.).

On the positive side, over the years the lot of the real time software developer has improved. Now-a-days operating systems provide powerful synchronization primitives and libraries of code. Also, commercial software development environments (such as Enterprise Java) take over the task of synchronization from programmers at the cost of some reduced flexibility.
DigitalDruid is offline  
Old 07-20-2003, 04:07 PM   #145
Veteran Member
 
Join Date: Feb 2001
Location: Hiding from Julian ;)
Posts: 5,368
Default

There ARE alternatives to if and goto, but... they ain't pretty.

Not for the Faint of Heart
Corona688 is offline  
Old 07-22-2003, 08:42 AM   #146
Veteran Member
 
Join Date: Feb 2001
Location: ""
Posts: 3,863
Default

Oooh, dont we just love massaging our egoes????!!!!!

Dont we?
Ted Hoffman is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -8. The time now is 03:13 PM.

Top

This custom BB emulates vBulletin® Version 3.8.2
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.