News for hackers. Stuff that matters.
Re:Pointer Free Programming and the Future of Nim by qznc on Friday October 20, 2017 @03:36AM (#15514127)
Exceptions (implemented zero-cost style) are truly zero cost. No dynamic checks as long as no exception is thrown.
Re:Pointer Free Programming and the Future of Nim by lmm on Friday October 20, 2017 @04:57AM (#15514417)
Exceptions aren't zero-cost either: they require you to be able to unwind the stack, so you have to keep the frame pointer and have one fewer general-purpose register to work with.
Re:Pointer Free Programming and the Future of Nim by cwzwarich on Friday October 20, 2017 @06:46AM (#15514786)
You actually don't need the frame pointer to unwind the stack. DWARF frame info allows the compiler to specify tables that describe the stack layout at every program point, and this can be used to perform unwinding.

Another reason why exceptions aren't zero-cost in practice is that compilers need to model the exceptional control-flow, and they usualy don't do a great job in this situation and miss a lot of potential optimizations.

Re:Pointer Free Programming and the Future of Nim by dbaupp on Friday October 20, 2017 @10:57AM (#15516265)
The cost being compared here is the 'if x.is_none()' or 'if x == null' check, not what happens after it.