chris@umcp-cs.UUCP (Chris Torek) (05/11/86)
In article <860@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >It's especially hard to impose order where there previously existed >little (e.g., arbitrary-goto-laden spaghetti Fortran 66 to C; I >know since I've done this by hand and often cannot easily cast out >more than half of the gotos in the code structure). There is a wonderful program in 4.[123]BSD called `struct'. It was written (as I recall---I cannot find any on line documentation, nor any author information in the source) by Dr. Brenda Baker at Bell Labs. It converts F66 to Ratfor, doing a truly amazing job. Struct should be applied to all old Fortran code at least once, just to see what it can do :-). (I do not know if it is available in System III/V, but if not, *why*?) There is a story I like to tell about this program. (It does not seem to impress the ones it should, unfortunately; but perhaps that is part of their very nature: else they would not use such code.) I once managed to convince a Physics grad student that Ratfor was better than `plain' Fortran. But the program on which he was working was already written, some thousands of lines of code that had been through at least four other hands before his. It had some subtle bugs, and I thought the best way to flush them would be to rewrite the whole thing in Ratfor; but he was unwilling to put that much time and effort into what was, for him, `throwaway code'. Of course, it had been throwaway code for each of the previous four authors, yet it had not been thrown away. Alas! they will not learn from history. :-) not learn from history. :-) ) Anyway, now I was at a loss: he had at last agreed that Ratfor was superiour, but had a very good reason not to use it after all. Then I found struct. I ran his code through struct, and showed him the result. Struct had replaced perhaps 90% of the `goto's with Ratfor loop constructs. I looked closely at one of the few remaining sections of code with gotos. I found out why none of the Ratfor loops sufficed for it. It was wrong. Alas, no, it was not `the last bug'; in fact, it was irrelevant to the Physics student's troubles, and had probably never surfaced at all. It was a fencepost error on a full array, and the authors had been careful never to fill those arrays completely. But it makes a good story nonetheless. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu