Of all the nails that could be used to seal Pascal’s coffin, the one I use is that I can’t write ‘writeln’ in Pascal. Other than that, it was great in it’s time (mid 70’s for me).
> malloc: Have a big static block of uint8_t and return pointers from it.
According to C99 section 6.5 paragraphs 6-7 that would be undefined behavior. The declared type of the object is uint8_t and you're accessing it through an lvalue expression which is not compatible with uint8_t. (You can access any object through a character-type lvalue, but the reverse is not true.) The malloc() function is required to return memory which is disjoint from any other object—that includes your uint8_t array.
Besides aliasing concerns, your character array may not be properly aligned for whatever type is being stored there and there is no way within the C99 standard to determine the alignment of the array or the required alignment for the stored type.
> exit: longjmp.
That might work, in a single-threaded program, if you longjmp() back to main() and return. There's no telling what might happen if you did that from another thread, of course, but then C99 doesn't really cover threads.
If you're lucky enough to be using C11 or C18, sure. There are no alignment keywords in C99. However, that still leaves the aliasing issue, and the fact that objects allocated with malloc() are defined not to overlap with any other object.
well you also need another static block for the allocation bitmap or whatever structure you're going to use. How would the pointers that you're generated be aliased if they're unique according to your free map.
That said, as far as at least Free Pascal goes, there isn't actually even a specific function called `writeln` with a real body that you can go and look at somewhere.
It's a magic language-level intrinsic that gets broken down into calls to various other intrinsics by the compiler based on what's passed to it.
According to Rosetta Code [1], “Standard Pascal does not allow variadic functions” — though specific implementations have proprietary extensions which allow this.
None uses that "standard" when writing stuff in Pascal. Real world uses either Delphi or Lazarus+FreePascal. Both of them have Writeln and variadic functions
Note, I think the point wasn't that Pascal didn't have writeln, rather that you couldn't write (implement) writeln in Pascal (presumably due to missing variadic functions).
So having writeln isn't really the issue, the issue is that writeln is magic/a built-in.
You could write something along the lines of `writeln` using `array of const` with today's Free Pascal. It's still strictly better that it's actually implemented as a built-in for various reasons, though.
Also, yes, Free Pascal is entirely self-hosted from the bottom up, making use of inline assembly blocks in some places where it's necessary. It is to Pascal what GCC is to C and C++, basically (which is to say, it has no real dependencies on toolchains other than itself).
Which compiler are you going to use for "standard pascal"? The Pascal compilers you're going to use in practice are either Free Pascal or Delphi. They are what Pascal is today:
You don't, it has to be in Assembly or calling underlying OS APIs.
So also a nail in C's coffin.