3 ms·
Functions aren't supposed to have side effects and procs are. It makes sense since functions without side effects would allow for some nice compiler optimizatio
by egonschiele 14y ago
Functions aren't supposed to have side effects and procs are. It makes sense since functions without side effects would allow for some nice compiler optimizations. The part that scares me is that the compiler doesn't enforce no side effects. This means you need to be extra careful when using someone else's code.
- andrewflnr 14y agoYeah, I got that, but gen's and proc's both have side effects. Why?
- Yttrill 14y agoBasically this is to support "expression" like syntax such as people are used to in C, for example i++ and x=y are expressions with side effects in C and a lot of C idioms depend on such things. This kind of thing was originally not allowed but I personally found it clumsy to manually split out the imperative parts from the functional parts, so I taught the compiler how to do it for me :)
- andrewflnr 14y agoBut those expressions also return things. Why can't they be gen? Why would I use a proc instead? It seems like I must be missing something, but I can't see it.