The perils of polishing old Fortran libraries
fortran-lang.discourse.group
fortran-lang.discourse.group
Within about 5 seconds I spotted he had forgotten a semi-colon from the end of an escape character and it was causing him all hell with rendering. I pointed it out right away but still looked over the rest to find errors and didn't find anything. He had a hard time believing it but trusted me enough to try it and alas I was correct.
From then on he treated me much better.
for (i = 0; i < 10; ++i);
func();
In one second I pointed out the extra ;. This does not remotely mean he was a bad programmer and I was a great one. It's just exactly the kind of thing where we see what we expect to see, not what is there. I make misstakes like that, too.But this experience is why D does not allow a solitary ; to represent an empty line. Modern C compilers spit out a warning for it, but geez, just make it an error already and eliminate the scourge of those bugs. I've seen other variations like:
if (condition);
doThis();With small scale computation (single process, single node), we have control over the entire universe. We just have to realize it and then figure out how to introspect it.
@natnatenathan I am glad you stuck with it, but the cognitive flaw that is very hard to get over is broken partial information. We have to rollback (forget our knowledge) and then learn it again fresh which can be incredibly hard, we skip over things we "think" we already know.
My object file disassembler will do that:
https://www.digitalmars.com/ctg/obj2asm.html
if the source code was compiled with debug info turned on. This feature has been around at least since the 80s.
That memory should make me feel old, I think. Calling a company about a programming job listed in the paper, whose challenge is now a bog-standard compiler warning? Those were the days
`null` has another meaning in D, that of a null pointer.
D also does not allow the syntax `a < b < c`. C does, to the eternal damnation of anyone who tries it.
Far be it for me to teach the Pope to pray, but would it be reasonably reasonable to make that do the right thing? If your compiler can disallow it, it can detect it, so the grammar is obviously thinkable, and the semantics might be as well.
The value of < is true if the numbers are in monotonically increasing order; otherwise it is false.
- clhsIt could also just be a type error: `<` takes two integers and produces a boolean, so both `(a < b) < c` and `a < (b < c)` would be invalid.
I did think about that, and it's a good question. I did not out of concern for some C code translated to D then mysteriously misbehaving.
Yet I am left to myself and my cat to explain the problem. I usually managev to find it by explaining the problem to the cat, rubber duck style.
I spent a good 30 seconds wondering if "++i" had some side-effect compared to the more usual "i++", before I saw the real problem, and I write C all day.
I remember trying to write my first programs in MS Notepad (which doesn't even have syntax highlighting) and then run them in Internet Explorer which would popup error messages one at a time in a dialog box. And a lot of time was spent finding and fixing trivial errors like this.
Are you an Ent? What you mean by "now" may not be what most other sentient beings understand here...
The program lint(1) was written in 1978, and the -W option for gcc appeared in the late eighties. For most of us, "this kind of tooling" has existed since before we were born. And I consider myself a graybeard!
However, specfically for JavaScript which is the language I was using when I first started programming it seems that the first linter wasn't released until 2011. At first there wasn't even `console.log`. I also think access to these tools has improved considerably. These days any introductory resource will point your towards VS Code which has a built-in marketplace which will install these tools for you at the click of a button (cross-platform!). That certainly wasn't the case even 10 years ago.
(I once told the Coverity folks that the mission of D was to put Coverity out of business!)
How does BetterC stack up to Zig and C++ in this situation? Does it allow me to write plain C but with some of the conveniences of D?
You've still got full use of metaprogramming, compile time function execution, modules, Unicode, all the memory safety features, etc.
> Does it allow me to write plain C but with some of the conveniences of D?
Heck yeah.
One was stuck learning C because they knew just enough about scope to be dangerous. They'd declared 'i' globally and used it in every subroutine for looping. Which failed confusingly when they called one looping function inside a loop in another.
No amount of insisting each function needed it's own 'i' would convince them. I left them to it.
O
and the digit 0You got me by a major release. My introduction to Fortran was Fortran 77 on an antiquated IBM mainframe (event at that time).
Loved it, even if I could never remember what column I needed to use :-).
What about assigned goto? hollerith?equivalence? Please look at the following:
C THE CALLEE
SUBROUTINE X(I)
GO TO I
END
C THE CALLER ASSIGN 10 TO J
CALL X(J)
C THIS IS NEVER REACHED STOP 10 WRITE(3,100)
100 FORMAT(8H THIS IS)
END
Why would this work? Because recursive calls are not allowed, There should NOT be a stack. So allow rather arbitrary jumped around (setjmp/longjmp) is um... ok?!? And what happens if a normal integer is passed to that code? (and it is separately compiled). Yikes.
C THE CALLEE
SUBROUTINE X(I)
GO TO I
END
C THE CALLER
ASSIGN 10 TO J
CALL X(J)
C THIS IS NEVER REACHED
STOP
10 WRITE(3,100)
100 FORMAT(8H THIS IS)
ENDMayhem be on you!
Nice.