4 ms·
What if your func iamsafe calls the proc imodifyglobals? More generally, can a "func" call a proc and remain a func?
by e12e 8y ago
What if your func iamsafe calls the proc imodifyglobals? More generally, can a "func" call a proc and remain a func?
- nepeckman 8y agoI'm not really a Nim expert, but I did a quick test on the scenario you laid out with these results: iamsafe could not call imodifyglobals, but could call a proc with no side effects. I'd guess that a func can call out to any proc that the compiler knows is side effect free, with the compiler erring on the side of caution.
- dom96 8y agoYep, AFAIK the compiler will do its best to infer the effects and most of the time it does a pretty good job.
- PMunch 8y agoNope, it can only call other side-effect free things. Note however if you call a procedure from a function the function will try to see if the proc is actually side effect free, just not marked as such. So you can still call a proc, but only if it could've been a func.