Does D has C#'s string.Empty?

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 25 18:34:23 PDT 2014


On Fri, 26 Sep 2014 01:08:59 +0000
AsmMan via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
wrote:

> but null has length? what's null in D?
no, it's dynamic array that have `.length`. compiler magic. assigning
`null` to dynamic array variable does some magic under the hood.

dynamic array is actually this: `struct { size_t len; void* ptr};`.
when you assign `null` to dynamic array variable, compiler generates
code to clear both `len` and `ptr`. think about dynarray var as kind
of 'fat pointer', which compiler knows how to operate.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140926/b9d18475/attachment.sig>


More information about the Digitalmars-d-learn mailing list