You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get an array containing the command line arguments. Be aware that this can change over the course of the program.
Does this mean the array itself may change? Because if that happens, then argv should return a clone of the array to keep users of the array referentially transparent.
Yes, the array itself can change, if you do something like process.argv.push('wat') in JS. I agree, cloning the array seems like the right thing to do. We might also consider exposing an API from this library that lets you mutate process.argv too.
I think I’d prefer just providing a pair of Effect functions to get and set these values, eg argv :: Effect (Array String) and setArgv :: Array String -> Effect Unit
The neat think on the ST Global stuff is we can skip having to write custom ffi for freezing arrays and objects (for env). We can even delete the current ffi for setEnv and unsetEnv.
We can always just hide the functions exposing ST Global if that's an issue. Or are we better off keeping it simple and dropping the ST Global entirely?
While it makes perfect sense to avoid FFI where possible in most contexts, I don’t think libraries whose purpose is to provide bindings to JS APIs is one of them. I think having custom FFI for these is fine.
Activity
hdgarrood commentedon Nov 27, 2016
Yes, the array itself can change, if you do something like
process.argv.push('wat')in JS. I agree, cloning the array seems like the right thing to do. We might also consider exposing an API from this library that lets you mutateprocess.argvtoo.thomashoneyman commentedon Dec 9, 2020
I think we should try and fix this for the upcoming 0.14 release for this library.
jvliwanag commentedon Dec 11, 2020
Perhaps we can simply set the type of argv as
STArray Global String? This adds a dependency on st though.jvliwanag commentedon Dec 11, 2020
Also, should we do the same for
execArgvandenv?hdgarrood commentedon Dec 11, 2020
I think I’d prefer just providing a pair of Effect functions to get and set these values, eg
argv :: Effect (Array String)andsetArgv :: Array String -> Effect Unitjvliwanag commentedon Dec 11, 2020
The neat think on the ST Global stuff is we can skip having to write custom ffi for freezing arrays and objects (for
env). We can even delete the current ffi forsetEnvandunsetEnv.We can always just hide the functions exposing
ST Globalif that's an issue. Or are we better off keeping it simple and dropping theST Globalentirely?hdgarrood commentedon Dec 11, 2020
While it makes perfect sense to avoid FFI where possible in most contexts, I don’t think libraries whose purpose is to provide bindings to JS APIs is one of them. I think having custom FFI for these is fine.