On Tue, 31 Mar 2009 06:46:32 +0400, dsimcha <dsim...@yahoo.com> wrote:

At times, like when trying to write a syntactically sweet tuple unpacker, I've wanted to be able to declare a variable that will be passed by reference to a
function inside the function call.  For example:

void doStuff(out uint num) {  // Could also be ref uint num.
    num = 666;
}

import std.stdio;

void main() {
    doStuff(uint foo);  // Declare foo as uint, passes it to doStuff.
    writeln(foo);  // Prints 666.
}

Is it feasible, at least in principle, to allow this, or would this create
issues with parsing, odd ambiguities that I haven't thought of, etc.?



It seems loogically that "foo" should die right after doStuff returns, because its scope is limited to parens. It's also redundant to specify type of foo, it can be deduced from function signature (auto foo?).

That said, I don't think there is a need for something like this. Certainly no speedup and little clarity compared to declaring variable right before invoking doStuff.

Reply via email to