4 ms·
It's not just the evaluation model; you have to know whether the compiler will perform transformations behind your back that increase space usage. If you were t
by cwzwarich 13y ago
It's not just the evaluation model; you have to know whether the compiler will perform transformations behind your back that increase space usage. If you were to impose a space semantics on the compiler and require that it preserve the semantics, a lot of optimizations would have to be disabled for lazy expressions.
It's not surprising that people manage to produce lots of working programs despite this, though. Almost all life-critical software is written in completely unsafe languages.
- chongli 13y agothe compiler will perform transformations behind your back that increase space usage This is not exclusive to Haskell; even C compilers will do this with jump tables and so on.
- cwzwarich 13y agoJump tables don't increase asymptotic space complexity, whereas some of GHC's optimizations will. You can also see how much jump tables increased the space usage of your program by inspecting the size of the compiled binary.