Declaring Ref Variables Inside Function Calls
dsimcha
dsimcha at yahoo.com
Mon Mar 30 19:46:32 PDT 2009
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.?
More information about the Digitalmars-d
mailing list