Saved for later, sounds interesting
This video had the basic for loop macro: https://stackoverflow.com/questions/69336050/how-to-implement-gos-defer-in-c-so-that-it-allows-declaring-vars
in real modern C can use cleanup, is more elegant
Here talk about defer FILE. void fcleanup(void* ppf){ if( *(void**)ppf) ) fclose(*(void**)ppf); } #define __cleanup(FN) __attribute__((cleanup(FN))) #define __fclose __cleanup(fcleanup) int main(){ __fclose FILE* f = fopen("file", "r"); ... }
I can't use compiler-specific extensions most of the time though
I use C compilers that aren't that good
For examples?
github.com/immortalvm/ivm-compiler
@TRGWII is zig basically just C ?
"C, but with the problems fixed"
It's based on GCC, probably have attribute cleanup
hmm this mean zig will replace C in the future ?
For some usecases for sure, but never all
It doesn't seem to me similar enough to C to replace it.
What problems
https://mrcat.au/blog/zig_is_cool/
It doesn't seem to give me what I really needed
cleanup code, failed integer hierarchy, implicit casts, defaulting to int, char signedness ambiguity, preprocessor, compilation model, no module system, no nuanced pointer types, ++
in C char not have sign. char != signed char char != unsigned char
of course the implementation will have to decide what to do with the abstraction
It is 'Cause of usual arithmwtic pattern
It actually does, but each implementation can pick, and that's my point
Even if it was just "char does not have signedness" that's still a huge problem
Many type in C not have a sign, many type are not signed or unsigned.
Okay so the problem is larger than just char then
No problems, you only Need to understand the type abstraction
It's not an abstraction, it's just a mistake
It's not a error, it's abstraction.
What do you gain from having this "abstraction" then?
You are free to use signed or unsigned value for char implementation
Обсуждают сегодня