Spec#, nullables and more

Christopher Bergqvist chris at digitalpoetry.se
Sat Nov 6 05:37:36 PDT 2010


On Sat, Nov 6, 2010 at 12:23 PM, Denis Koroskin <2korden at gmail.com> wrote:

> On Sat, 06 Nov 2010 14:06:20 +0300, Christopher Bergqvist <
> chris at digitalpoetry.se> wrote:
>
>  Does D have anything comparable to C++ references à la "void
>> nullCheckLessFunction(const std::string& notNullStr) {...}" or does it
>> only
>> have the equivalent of "void nullCheckingRequired(const std::string*
>> mightByNullStr) {...}"?
>>
>
> void nullCheckLessFunction(ref const(string) notNullStr) { .. }
>

I made two comparison snippets between D & C++.

http://ideone.com/VPzz6 (D)
http://ideone.com/HzFRB (C++)

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101106/c3c74716/attachment.html>


More information about the Digitalmars-d mailing list