5 ms·
Cdecl – C gibberish ↔ English
- tyingq 6y agoGoing beyond declarations with this idea: https://www.cs.cmu.edu/~dst/DeCSS/Baccash/ https://www.cs.cmu.edu/~dst/DeCSS/Baccash/
- hzhou321 6y agoThat English does not make it easier to understand.
- gopiandcode 6y agoI think a visual representation of a concrete instance of the type would probably be a better explanation of c type declarations. At the moment this tool seems more a C gibberish to english gibberish translator.
- tempodox 6y agoThat's why in practice, you should avoid declarations like that. Break down the components into separate `typedef`s with descriptive names that are easy enough to understand in isolation. Then combine those stepwise following the same rule.
- scaramanga 6y agoAmen
- quietbritishjim 6y agoAgreed. They turned this declaration: char (*(*x())[5])() into this English description: > declare x as function returning pointer to array 5 of pointer to function returning char What was really needed was just to disentangle the function declarations, like this: x: fn () -> &((&fn () -> char)[5])
- larzang 6y agoMy immediate reaction isn't "this is so cool and useful for me" but "this might be really useful over traditional speech translation for programmers who can't use their hands". If you know the code but have difficulty inputting it, this might have real value even if it has none for making understanding the code easier.
- sedeki 6y agoFunny. The K&R book implements this program if I recall correctly.
- godelmachine 6y agoI never tried using Unicode characters while posting on HN. Was under the impression they don’t work here. Will try next time
- exikyut 6y agoCompletely offtopic, but TIL Arc allows U+2194 in titles!
- tempodox 6y agoShould work with all Unicode that the font your browser uses has glyphs for. You see UTF-8 decoded and rendered, I don't think Arc does anything special with it. When you look at the page source you can see that the “↔” isn't given as an escape sequence or an HTML entity.
- boltefnovor 6y agoGenius. This should be built into IDEs.
- flohofwoe 6y agoTBH, if you need such a helper the code is way too complicated and entangling such messy types first would be preferable and makes the code more readable for everyone.
- tuatoru 6y agoIt should be possible to make a COBOL-ized C with this - a language with the semantics of C (and broadly analogous syntax, mutatis mutandis) and the wordiness of COBOL. I wonder if it's already been done?
- innocenat 6y agoI imagine you can probably do that with C preprocessor.
- shakna 6y agoLike this? #include "evil.h" Main then displayln("Hello, World!"); end [0] https://git.sr.ht/~shakna/cnoevil3/ https://git.sr.ht/~shakna/cnoevil3/
- Turing_Machine 6y agoMany years ago a friend of mine had a hobby project to try to implement BASIC using the C preprocessor. The idea, which seemed rather cockamamie at the time, was to come up with something you could feed a BASIC program to and have it come out as a compiled executable. Nowadays, that kind of idea is everywhere, of course. I don't know if he ever got it finished (or indeed, if it's even possible in a practical sense. The C preprocessor is Turing-complete (edit: more or less, if you're allowed unlimited runs), so it's obviously theoretically possible).
- papaver-somnamb 6y agoTwo keys to readable C declarations: 1. Just read the clumps in a given decl backwards. 2. Keep the decls of individual concepts in code small enough to grok without breaking your brain. While decls can be mechanically complex, ability to reason about and maintain code is a paramount factor. For C, typedef, struct, nomenclature are friends. You know, returning an array of triplets of function pointers each of which accept more gloop can be made to be understandable with judicious application of the above. I'm given to understand that this overall approach is all the rage in the Go community ...
- Fudgel 6y agoThis seems like it might be useful to disabled coders.
- deleted 6y ago[deleted]
- sixplusone 6y agoFor anyone else wondering: "cast into block" (^) is a non-standard lambda/closure declaration in C. Also, Ritchie could have saved a lot of people a lot of hurt by using a "func" keyword.