3 ms·
> black magic of the nether regions Or plain abstraction violation. “Black magic” gives it an undeserved good reputation: “I must aspire to be clever enough to
by catnaroek 10y ago
> black magic of the nether regions
Or plain abstraction violation. “Black magic” gives it an undeserved good reputation: “I must aspire to be clever enough to understand and actively make use of this.”
- kbenson 10y agoMaybe. Given it relies on the calling convention of the OS you're on, the CPU architecture you're on, and knowledge of assembly, it could very well be both.
- int_19h 10y agoIt also relies on implementation-specific behavior in the compiler, since the latter is not actually required to follow established the convention for argument passing, so long as it can prove that the only place the function is called from is the same translation unit. In fact, so far as I can tell by looking at the first example, the compiler can circumvent this whole thing by noting that: 1. DoubleToTheInt is only ever called in the same unit, so it can be inlined - no need to generate the function. 2. Pointer to DoubleToTheInt is created, but is then immediately cast to an incompatible function type, which is undefined behavior - and so it can be substituted with any random value, say, whatever happens to be in EAX at that moment (any U.B. is substitutable for any other U.B.!), and the compiler can still avoid generating the actual function.
- chriswarbo 10y ago> “Black magic” gives it an undeserved good reputation From http://catb.org/jargon/html/B/black-magic.html http://catb.org/jargon/html/B/black-magic.html > black magic: n. > [common] A technique that works, though nobody really understands why. More obscure than voodoo programming, which may be done by cookbook. Compare also black art, deep magic, and magic number (sense 2).