HibernateD and DDBC - ORM and DB abstraction layer for D
Diggory
diggsey at googlemail.com
Tue May 21 17:10:52 PDT 2013
On Tuesday, 21 May 2013 at 22:24:06 UTC, Nick Sabalausky wrote:
> On Mon, 06 May 2013 11:14:56 +0200
> "Kagamin" <spam at here.lot> wrote:
>
>> On Monday, 29 April 2013 at 09:38:10 UTC, David wrote:
>> > Null blows up your code, "" doesn't.
>>
>> There's no difference between null and empty string in D.
>>
>
> That's not true:
>
> assert("" !is null); // Passes
>
> Or did I misunderstand what you meant?
Strings are slices which are a pointer and a length. I think a
slice compares equal to null only if the pointer part is null.
However, a slice with a null pointer and a length of zero is
still a valid empty slice, which is slightly odd behaviour
compared to other languages...
An empty string literal initialises the pointer to non-null
because string literals are null terminated, so the memory block
actually has a length of one, even though the slice has length
zero.
More information about the Digitalmars-d-announce
mailing list