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
Fix Issue 11308 - Don't use Voldemort types for std.process output #2085
Conversation
Yes, this is a no brainer. If you used a different string width for the command line, it also would prevent reassignment. Not sure it needs to be made private. But it was a voldemort type originally, @kyllingstad ?. |
Both functions are actually supposed to return |
This is a bug I've filed already: https://issues.dlang.org/show_bug.cgi?id=11308 |
What is the motivation for wanting to return a tuple? Seems just as convenient to return a named type to me. |
Awesome. I've re-based and tagged my commit/pull accordingly. |
Seems like the prototypical use case for a |
Hum... I thought they weren't POD's, because they have elaborate assigns and constructors. But apparently, the elaborate assigns doesn't get in the way.
Yeah, that's probably a good argument. I'm fixing it now. EDIT: In a couple hours :) |
return ProcessOutput(wait(p.pid), cast(string) a.data); | ||
} | ||
private struct ProcessOutput { int status; string output; } |
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 think right from the get-go we went a bit overboard with hiding everything under Voldemort/private structure types. It's useful for hiding things that have an API, e.g. ranges, but in this case I think it's overkill. It's essentially forcing people to use auto
, even if some people like typing a variable explicitly, or e.g. want to store the structure to a field (they'd have to use typeof()/ReturnType tricks and whatnot).
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 completely agree. There are several times when I've been thoroughly annoyed that I couldn't easily store a voldemort type in a struct field without resorting to ugly tricks. However, in this case, the reason was to avoid breaking client code when we made the change to Tuple
. When we make the change now, existing code will be source, and maybe even binary, compatible.
Awesome, thanks! :-) |
Btw, I think both |
Allright. I've now changed it (and That said, I was surprised to notice that the code ran fine without any import of typecons whatsoever. Must be some 313/314 issue thing. Yet I thought they were fixed? In any case, I think this should wrap it up? Unless there's anything else you might want me to address? |
LGTM. Only nit, and I'm not sure if this is correct, but you put: "An |
I've often wondered about this myself. I guess it depends on how you pronounce it? That is, "a standard typecons tuple" versus "an ess tee dee typecons tuple". |
and $(D int status). (This will most likely change to become a | ||
$(D std.typecons.Tuple!(bool,"terminated",int,"status")) in the future, | ||
but a compiler bug currently prevents this.) | ||
An $(D std.typecons.Tuple!(bool, "terminated", int, "status")). |
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 think the whole "Returns" section could be removed, as it no longer provides any additional information beyond what is already in the function signature. Also, further up, in the second paragraph of this doc comment, you could replace
it returns a struct where
with
it returns a tuple where"
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 missed the above "struct"/"tuple" thing. Fixed now.
So that the return type of `execute` and `executeShell` are compatible.
Auto-merge toggled on |
Fix Issue 11308 - Don't use Voldemort types for std.process output
So that the return type of
execute
andexecuteShell
are compatible.Long story short, because the structure was declared in the template, it created two different types. This prevented the use of a single
ret
object:So this "unlocks" that.
@schveiguy , I think you can review this?