RFCs
RFCs copied to clipboard
Const section should check for side-effects
import os
const
foo = getHomeDir() / "asd"
The above code should raise an error.
Well, in this case yes, but I think one may very well want to perform side effects in consts - for instance read something by a configuration file and have it stored in the binary
Good point.
Any other ideas on how we could prevent the above gotcha? Simply removing compile-time getHomeDir
would work but I'm sure there are cases where it would be useful also.
We can try and make getHomeDir work in the VM but not in a const section, these have separate code paths already iirc. And for now only getHomeDir did bite us.
This RFC is stale because it has been open for 1095 days with no activity. Contribute a fix or comment on the issue, or it will be closed in 30 days.
Too useful to close it.