|
|
|
|
|
by heavenlyhash
4280 days ago
|
|
> My favourite solution by far, though, is the one recently implemented by Elixir: log() is a regular function, but takes a closure instead of a string. This is a pretty fantastic route as far as syntactical simplicity goes. I wonder if it can have an implications on the generated assembly nonetheless? Could there be extra assembly generated outside the branch for logging level check, which is necessary to bind the variables for the closure? Similarly, I might suspect that an optimizing compiler that is considering a function for inlining might change its mind for any function where it sees a nontrivial closure like that, without knowing that "trace" level logging nearly never happens. "Edge cases", to be sure, and the answers are surely different between languages, but interesting to consider nonetheless. |
|