-
-
Notifications
You must be signed in to change notification settings - Fork 706
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
add opIn for std.process.environment #4941
Conversation
5be747e to
e05eb53
Compare
|
|
e05eb53 to
dfbfac6
Compare
|
ping anyone? Does this need andralex approval for a new symbol? @CyberShadow or @schveiguy perhaps? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about the Windows API, so I just stick to point out two nits.
| // failures | ||
| throw new WindowsException(err); | ||
| } | ||
| else static assert(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should always be a message for assert(0)s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does phobos even support anything other than posix or windows? I only put these in as sanity checks for future porters.
| doSomething(var); | ||
| ------------- | ||
| */ | ||
| bool opBinaryRight(string op : "in")(in char[] name) @trusted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why you don't use string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency with the rest of the environment API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in char[] is preferable over string when immutability is not required (i.e. we don't save a reference to the string, or a slice of it, past the function's return), because this allows calling the function with const or mutable char arrays.
I am not sure - I just tagged it with the motivation of "better be safe than sorry". |
|
I remember I asked for The diff looks good to me though. |
|
The reason I didn't add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
ping @andralex |
std/process.d
Outdated
| @@ -3251,16 +3293,20 @@ private: | |||
| // New variable | |||
| environment["std_process"] = "foo"; | |||
| assert (environment["std_process"] == "foo"); | |||
| assert ("std_process" in environment); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW (and I realize you're sticking to existing style) I think Phobos style is to treat assert like a function, not a keyword (i.e. no space before ().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah, no space after assert cc @wilzbach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #5169 for an enforcement and automatic unification of this assert style ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx!
std/process.d
Outdated
| @@ -3251,16 +3293,20 @@ private: | |||
| // New variable | |||
| environment["std_process"] = "foo"; | |||
| assert (environment["std_process"] == "foo"); | |||
| assert ("std_process" in environment); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah, no space after assert cc @wilzbach
|
Changed all the asserts in the file to the correct format |
FWIW #5169 does this for entire Phobos in one go, but it doesn't hurt. |
Useful because:
getgeton windows & posixWhy does it not return a
stringwith the variable? Because that would mean it was just an alternative syntax forgetand pretty pointless.Why not do something clever and return a
const(string)*in order to fully mimic an AA? Because I don't think there's any way of doing that even close to efficiently.