[phobos] Preferred style for multivalue returns
Lars Tandle Kyllingstad
lars at kyllingen.net
Sun May 2 14:30:18 PDT 2010
What follows may be a trivial design question, but it's not the first
time I've run into it, and I'm trying to figure out what is the "Phobos
style" for various things.
I want to add a function to the new std.process that waits for the first
child process to terminate, and returns its exit status AND process id,
but I'm having trouble deciding on a signature for it.
What do you find to be the preferred style for functions with multiple
return values?
// Both of these are simple, but the choice between them
// is kind of arbitrary (i.e. why should x be the "real"
// return value?)
Pid waitAny(out int status);
int waitAny(out Pid pid);
// Introducing a completely new type just for this?
struct WaitResult { Pid pid; int status; }
WaitResult waitAny();
// I personally find the following pretty elegant, but
// perhaps a bit verbose? And I don't see Tuple being
// used much elsewhere in Phobos. (Why?)
Tuple!(Pid, "pid", int, "status") waitAny();
...others?
-Lars
More information about the phobos
mailing list