5 ms·
Ah, finally a modern successor to Bournegol: http://oldhome.schmorp.de/marc/bournegol.html http://oldhome.schmorp.de/marc/bournegol.html
by roywiggins 7y ago
Ah, finally a modern successor to Bournegol: http://oldhome.schmorp.de/marc/bournegol.html http://oldhome.schmorp.de/marc/bournegol.html
- shakna 7y ago#define TYPE typedef #define STRUCT TYPE struct #define UNION TYPE union Well, that's extremely opinionated. Which I guess is the point. It does seem to add a BASIC-ness to the code. However, when I see landmines like these: #define TRUE (-1) #define FALSE 0 I might just hide instead of touching it.
- stiray 7y agoUh... This is serious landmine... I suggest author to change this.
- shakna 7y agoThis particular code isn't about the post. It's about Bournegol, which doesn't actually exist anymore, and is actually quite hard to track down any examples of.
- kick 7y agoIt's...not, though? The Bourne Shell was released under a free license years ago along with the rest of v7, and it's just a macro hack. Very much still exists, and pretty easy to find. https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh
- thrwaway69 7y agoCan you explain why?
- Tervis 7y agoOn C language an expression which evaluates to any non-zero value is considered as True. So for example this kind of statement would not likely behave as intended: if (TRUE == expression) { ... }
- Koshkin 7y agoI have refused to hire people who did this. (FALSE, too, even though it is safer.)
- shakna 7y agoTo emphasise: This is about Bournegol. Nothing to do with this post. > Can you explain why? Because it isn't how most C libraries expect true/false to be defined. stdbool in C99 standardized things a bit, but before then what was generally accepted was: > true is 1 > false is !true (Often 0 in practice). Which means that any trivial: if(true) { ... } Won't work under Bournegol. Instead you _need_ to compare when doing an if statement. So the C-programmer is easily tripped up. False will work as expected, but True won't... All the time. There may be times it does work. Leaving the programmer throwing their hands in the air.
- thrwaway69 7y agoAh. Thanks for the explanation.
- kaetemi 7y agoMost cases I've seen accept anything as true as long as the LSB is 1, and quite strictly 0 as false. Everything else is up in the air. The value -1 is definitely true. :)
- ufo 7y agoOne could say that -1 is the truest true, because its two's-complement representation has the most 1s.
- kick 7y agoThe author is 76, and retired. This is from UNIX v7, before the standardization of C.
- mst 7y agoDon't bash it til you understand it.
- kick 7y agoIt's an ALGOL-derivative, not a BASIC-derivative. It's trying to be ALGOL. Bourne was one of the few people to write an ALGOL-68 compiler. I might just hide instead of touching it. This code (the Bourne Shell source) is actually the reason why the IOCCC was created.
- mhd 7y agoI know it's bad preprocessor magic, but I kinda liked that. I thought about hacking together a quick "Oberon-ish" to JS "transpiler" for a while, of course going along with a decidedly Wirth-ian code style. I might call it "werenotwirthy". But there's also the appeal of the dreaded Incunabulum...