<div class="gmail_quote">On Sat, Nov 6, 2010 at 12:23 PM, Denis Koroskin <span dir="ltr"><<a href="mailto:2korden@gmail.com">2korden@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Sat, 06 Nov 2010 14:06:20 +0300, Christopher Bergqvist <<a href="mailto:chris@digitalpoetry.se" target="_blank">chris@digitalpoetry.se</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Does D have anything comparable to C++ references à la "void<br>
nullCheckLessFunction(const std::string& notNullStr) {...}" or does it only<br>
have the equivalent of "void nullCheckingRequired(const std::string*<br>
mightByNullStr) {...}"?<br>
</blockquote>
<br></div></div>
void nullCheckLessFunction(ref const(string) notNullStr) { .. }<br>
</blockquote></div><br><div>I made two comparison snippets between D & C++.</div><div><br></div><div><a href="http://ideone.com/VPzz6">http://ideone.com/VPzz6</a> (D)</div><div><a href="http://ideone.com/HzFRB">http://ideone.com/HzFRB</a> (C++)</div>
<div><br></div><div>I feel like C++ is one small step ahead of D in this respect. It's not possible to trust that C++ references are non-null, but at least they serve as concise documentation of the expected contents and tend to make surrounding code perform the null-check up front before dereferencing from pointer to C++ reference.</div>