User talk:Dinosaur: Difference between revisions

Line 59:
 
::A while ago I helped a fellow with a weird and unexplained programme that turned out to be a numerical simulation of an artillery gun firing a shell (recoil, etc. in sub-millisecond steps), written in a hybrid of special simulation language phrases mixed with plain Fortran source that would be fed to a processor that would spit out ordinary Fortran source, that would be compiled and run. I get the same feeling when looking at the variants written in the many rather different languages: no explanation of what something does - is it a built-in facility/notation, a standard library item, a feature from a popular extension library, ''etc''. With no indication of the plan of attack, nor what guided various choices, one is adrift in a fog. Though I have also had similar experiences looking at old code... The InsertionSort method admits of many tiny variations in usage, often involving dodging or introducing wasted actions. The version you introduced for example involves a wasted test on J, required because the strictures of structured programming make it difficult to avoid, especially since Fortran does not offer a ''repeat ... until test'' construction that would avoid an un-needed initial test in that formulation of the method. Which is why I left the compound expression in (but commented out), for matching with with the example code at the head of the article, rather than introducing a non-matching form. Someone might read that and conclude that the compound form, as in the example, is so much better...
::The example code at the head of the article relies on short-circuit evaluation without mention (even though the Wikipaedia article does warn on this) and many of the examples in the various languages also appear to rely on partial evaluation too, without remark, matching the example code, or not matching it, without remark. This may be correct, if short-circuit evaluation is the style for that language, or it may be incorrect. The correctness you praise then relies on the unmentioned details of a particular language, unknown to non-users of the language, and probably not in the front of the consciousness of the author either. Put another way, the same algorithm would succeed or fail in various languages, depending not on the source code, but on the choice of a recondite detail of the language's implementation that may or may not be specified in one standard or another that a particular compiler/interpreter/programmer may or may not follow. The original author did after all test their version and found that it worked. There are innumerable programmes that have worked when checked, and worked throughout their use (apparently), and when transferred to a different compiler, fail. I suppose there is "correct" (the damn thing works) and "Correct", the latter being so for code that will work for all variants of a compiler - correct compilers only, of course. But for complex programmes, "Correct" is a numinous state and unattainable, since over time the language standard is revised to mention newly-discovered ambiguities, or, change their interpretation. As a historical example, the DO-loop interpretation oncein early Fortran always executed at least once, since the test was made at the end of the loop - and in those days there was no separate standard as such, what the specific compiler did ruled. For most loops this saved a test, and sometimes it was desired behaviour in certain situations (such as this one!) though not in others, and the latter choice became the approved way. Without change to the code, a correct prog. becomes incorrect through change to an entirely separate item. Unfair!
::But yes, I'll admit that I think that short-circuit evaluation is correct, and that code that works with that is correct (especially when it is tested and works correctly), and that the order of evaluation of expressions is fully defined (tie-breaker rule: left-to-right for equal precedence), and I resist the more recent Fortran specifications whereby, maddeningly, it is specified that this is not specified. Because I think that is incorrect... Time for a drink. Cheers, [[User:Dinosaur|Dinosaur]] ([[User talk:Dinosaur|talk]]) 02:26, 31 December 2017 (UTC)
1,220

edits