Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • To start with, Ada indexes arrays starting with 1. Yes, I know that is ugly and weird (*cough* FORTRAN *cough*), but that is most certainly not an off-by-one error.

    Next, neither your p6 code or the java code addresses the line:

    subtype LogFileIndexT is LogFileCountT range 1 .. MaxNumberLogFiles;

    Granted there are some missing values here, specifically LogFileCountT and MaxNumberLogFiles. But these two help to define a range of acceptable indices for the LogFileNamesT array type.

    Now to the really bad assumptions, the following two lines:

    subtype FileNameI is Positive range 1 .. 16;
    subtype FileNameT is String(FileNameI);

    were completely misinterpreted by the blogger, this is not saying "only allow 16 log files in my array", it is saying that the file names are only allowed to be a string of 16 characters long. The actual number of allowed log files in the array is determined by MaxNumberLogFiles, which I suspect has to be less then 100 since otherwise the strings would be too long.

    Now, as for the question of why so static? Probably because this code is meant to run in an embedded system which has very limited resources so the more specific the programmer can be about the size and shape of the memory they want to use (an array MaxNumberLogFiles long made up of 16 char strings) the more efficient the compiler can be about allocating that storage.

    As for why they hardcoded the first 17 log file names, I am suspecting this is because this code was also written for what I called a hard real-time system, which means it must, and I mean MUST perform a task within a given time frame and failure to do so could likely endanger peoples lives. By hardcoding the first 17 files they are probably saving precious CPU cycles (17 must be some kind of magic number, a sweet spot if you will) and (as one of the commenters pointed out) possibly helping some kind of formal proofing tool.

    Lastly, the fact we would (in p6) get a runtime exception would in no way shape or form be acceptable for a safety critical system. Would you really want to have the pilot of the plane you are flying have to deal with a stack trace from some kind of runtime exception? Or the safety inspector (Homer Simpson anyone) at the nuclear power plant to have to figure out what just blew up in the code before the core melts down and actually blows up?

    Ada is not pretty, it is not friendly, it is not agile, it is not clever. It is tedious, ugly, draconian and safe.

    - Stevan

    • And what people miss is that while this sort of safety is a must when lives are on the line, it is prohibitively costly to achieve in, say, one-liners.

      But programmers like to view the world in black&white.

    • Stevan, thanks for all of the background information here. It's nice to get a different perspective on things.

    • 16 is the magic number, even in ADA there is 2-complement HW.
      index 1-17, count=16

      I also deal with security relevant hard real-time code. We mostly use graphical environments there, Matlab Simulink, the deal with the additional complexity.

      There the checks are mostly runtime, not compile time! "Compile time" checks are done by the graphical environment, where boxes simply cannot be connected, or invalid parameters cannot be entered.