2 ms·
This is great stuff; if I were ever to write a language this sort of side-effect control is something I would like to include. That being said, I'm bit surpris
by zokier 9y ago
This is great stuff; if I were ever to write a language this sort of side-effect control is something I would like to include.
That being said, I'm bit surprised how much effort developers put into "tricking" C compilers; one would think that writing pieces of (inline) assembly would provide the desired effect while being both easier and more robust. At least it feels like in many cases the developers have some idea on what the desired code is. Maybe there are some subtleties that I am missing?
- krupan 9y agoAssembly is not portable.
- nine_k 9y agoAre the tricks portable?
- quacker 9y ago"portable" in the sense that the compiler will produce the proper assembly for the platform - choice of x86, ARM, MIPS, 32/64 bit, etc. Whether the "tricks" behave identically across all platforms depends on the trick, I think.
- pjmlp 9y agoUsually those tricks are not even portable across compilers on the same platform. It suffices a change on compiler version with optimizer improvements, or using another vendor's compiler for the tricks to fall apart. In a gigantic code base, with rotating developers, it becomes a very "fun" thing to debug.
- coldtea 9y ago>Usually those tricks are not even portable across compilers on the same platform. That's much less of an issue. If it can work on GCC for example or Clang across platforms, you're OK for tons of platforms, even if you can't change compilers intra-platform.
- saagarjha 9y agoAssembly is presumably harder to write, audit, and port to other platforms.