9 ms·
Well, as mentioned that's why you create two lambdas as the branches. This is pretty much what thunks are in some languages (like Haskell), so this example does
by gf000 3mo ago
Well, as mentioned that's why you create two lambdas as the branches. This is pretty much what thunks are in some languages (like Haskell), so this example doesn't strictly require macros per se.
- KingMob 3mo agoThis is true, but thunks carry overhead that macros don't in this case.
- gf000 3mo agoWell, if we have a compiler that sees a constant value, it can completely optimize out one branch. But it of course depends on the semantics of the language. But yeah you are right in case of a naive compiler.
- BeetleB 3mo agoAnd I know people will think I'm crazy, but thunks are harder to read. (And I have trouble reading macros).