2 ms·
What you say is certainly possible but it does not seem that it would lead to a beautiful language with a beautiful specification.
by enriquto 7y ago
What you say is certainly possible but it does not seem that it would lead to a beautiful language with a beautiful specification.
- pjc50 7y agoIf you consider the C specification beautiful it can only be because anything ugly is simply left unspecified. Large parts are simply missing. It only seems straightforward because so many of the weird architectures and platforms have failed and we're left with 32/64 Intel/Arm as the only ones most authors consider. The C spec allows one's complement arithmetic, but how many programs would break horribly on such a machine?
- jstimpfle 7y agoI neither consider the C specification beautiful, nor do I think that large parts are missing. In fact, the specification goes to great lengths to allow implementations on a wide range of computers. I will claim that most other languages specifications only seem so straightforward because they have a simpler execution model, where some of the things you can do in C are simply not possible, or where the spec is exclusively targeted at more modern machines. (And that's a good thing for most applications).
- dependenttypes 7y agoYou would be incorrect. Languages with proper type systems tend to have a much simpler specification when compared to C.
- enriquto 7y agoI mean a language that checks your arbitrary pointer arithmetic when the compiler is able to, otherwise it is not a valid program.
- kragen 7y agoI think you're probably right. I think it may be difficult to design a dependent type system that ⓐ easily checks common pointer arithmetic idioms, ⓑ rejects programs predictably rather than unpredictably, and ⓒ upon rejecting a program, offers clear guidance on how to modify the program so that it can pass (perhaps at the cost of adding an impossible error case or a redundant run-time check). But I'm no expert, so I could be wrong about that. However, C has quite a bit of ugliness in its own definition, and it might be possible to remove a lot of that.
- dependenttypes 7y agoI don't mean anything different. Right now the C specification is nearly 700 pages long. In the meanwhile you can easily define a dependent type system within two pages.