3 ms·
I don't think this makes the case for elegance at all. Global vars set wherever in a program are preferable to explicit params when creating a new process? And
by MichaelGG 10y ago
I don't think this makes the case for elegance at all.
Global vars set wherever in a program are preferable to explicit params when creating a new process? And there's no way to have default params or anything?
- lmm 10y ago> Global vars set wherever in a program are preferable to explicit params when creating a new process? The outside world is always going to be implicit global mutable state; spawning an arbitrary process to do who-knows-what is inherently that kind of problem. If you could express it as an actual function you wouldn't need to run a separate process. > And there's no way to have default params or anything? Well not in C. You can sort-of do it by having a struct with fields that you fill in where all-bits-zero is the default but that's generally more trouble than it's worth.
- MichaelGG 10y agoWell by that reasoning there's never any need for function purity since you can't eliminate global state on current computer designs. C easily allows you to have multiple functions. exec_with_current_state or something. And a struct is a way, too.
- lmm 10y ago> Well by that reasoning there's never any need for function purity since you can't eliminate global state on current computer designs. If you care about purity you don't use spawn-like functionality at all. > C easily allows you to have multiple functions. exec_with_current_state or something. That doesn't help. You'd need to have one variant where you just want to change the working directory, one variant where you just wanted to set an environment variable, one variant where you want to do both, one variant where you want to run as a different UID and change working directory but not touch the environment variables...