-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Modify and retrieve the local environment variables #120
Comments
I think myself a new As far as methods are concerned, I'd just mimic most of what we have in the So we'd have:-
I'd omit Some examples to see how this would look: var path = Env["PATH"]
Env["PATH"] = "/usr/bin/"
var c = Env.count
Env.remove("WHATEVER")
for (key in Env.keys) System.print("%(key) = %(Env[key])")
for (me in Env.entries) System.print("%(me.key) = %(me.value)") |
Although the environment is a property of a process, from an interface perspective, a separate Env module is nicer. For me, the environment is a collection of NAME=value pairs. Calling them "keys" doesn't sound right.
If Env can have Sequence as a superclass, like Map, then you get all the iteration mostly for free
|
I was worried since the underlying data comes from the OS via syscall... so that's why I went with
Yes, we should prefer simple, not easy. If the domain is different then the naming should be natural to the new domain. IE, not every "hash-like" object should have a Map interface verbatim. |
Still needs some native functional methods:
And that |
I'd say those would have to be deferred to Map, since again those things depend on the itterable protocol, and we do not have that data to iterate over - it could be changing out from under us, etc... We could write naive ones, but to be a good Wren citizen they should be a |
I should also say with many things like this I'm in favor of "minimal viable functionality" vs "get it 100% the first pass"... if we only supported some basic functionality in a first pass and then went back later and added more, that'd be great. Of course we can still discuss the full scope here, but I wouldn't prefer to limit an initial implementation to 100% if say 80% was super useful to have. To me iterability is one of those "nice to have", but not "required" items. (doubly so if you can get it via |
I hear you. |
I may need this soon and I wanted to get thoughts/feedback on the API. We'd likely need to wrap:
Perhaps:
To me the
[]
andget
,set
,unset
seem reasonable it's theall
andtoMap
I'm wondering if anyone has any better ideas for accessing the entire environment at once. I also thoughtProcess.env
seemed nice, but one could also imagineProcess.environment
or evenEnvironment
on it's own I suppose.Related: joshgoebel#11
The text was updated successfully, but these errors were encountered: