HibernateD and DDBC - ORM and DB abstraction layer for D
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Tue May 21 17:18:44 PDT 2013
On Wed, 22 May 2013 02:10:52 +0200
"Diggory" <diggsey at googlemail.com> wrote:
> 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.
Right, exactly. In other words, there *is* a difference between null and
empty string in D (even though it's sometimes a clouded issue since
'==' counts them as equal).
More information about the Digitalmars-d-announce
mailing list