<div dir="ltr"><div>This is kinda rhetorical, since I've asked this a million times, and we all know the answer... but seriously; why can't we declare ref locals?</div><div><br></div><div>Lots of functions return a ref; and we need to capture the result of those functions appropriately.</div><div><br></div><div>ref T f();</div><div><br></div><div>void t()<br></div><div>{</div><div>  ref T result = f();  // <-- there's no good reason to reject this<br></div><div>}</div><div><br></div><div>I don't understand why this doesn't come up every few days, everytime a new user appears. Is this really okay? Why does this make me feel so frustrated, but nobody else seems to care?</div><div><br></div><div>... "Use a pointer!" ...</div><div><br></div><div>void t()</div><div>{</div><div>  T* result_ptr = &f();  // seriously?<br></div><div>}</div><div><br></div><div>I feel embarrassed by this suggestion, why don't you feel embarrassed by this suggestion?</div><div>It's also pretty shit that taking a pointer of a function's result like that is not compatible with ufcs, where it instead attempts to create a function pointer.</div><div><br></div><div>It gets worse when the function is property-like.</div><div><br></div><div>void t()</div><div>{</div><div>  T* prop_ptr = &myThing.prop;<br></div><div>}</div><div><br></div><div>
error: cannot implicitly convert expression `& f` of type `T delegate() ref` to `T*` <br></div><div><br></div><div>A new D user will look at that and think it's stupid... at least; I look at that and I think it's stupid!</div><div>ref locals already please, this has gone on long enough!<br></div></div>