On Sun, 12 Dec 2010 04:00:36 +0100
Simen kjaeraas simen.kja...@gmail.com wrote:
So likely, idup on an empty string returns an array with null ptr and
0 length, while is 'allocated' in the data segment, and thus given a
ptr value.
.dup .idup should not change a string's truth value. For
spir denis.s...@gmail.com wrote:
On Sun, 12 Dec 2010 04:00:36 +0100
Simen kjaeraas simen.kja...@gmail.com wrote:
So likely, idup on an empty string returns an array with null ptr and
0 length, while is 'allocated' in the data segment, and thus given a
ptr value.
.dup .idup should not
string s = ;
assert(s); // ok
assert(s != null); // fails
I guess that's a bug. But which one is right?
--
Tomek
I forget, why are we supposed to use is instead of == with null?
On 12/11/2010 08:18 PM, Tomek Sowiński wrote:
string s = ;
assert(s); // ok
assert(s != null); // fails
I guess that's a bug. But which one is right?
--
Tomek
The first one should fail since the string has length 0. If you use an
.idup you would get the correct results:
void main()
{
string s = .idup;
assert(s); // fails
assert(s != null); // ok
}
So I guess it's a bug.
On 12/12/10, Tomek Sowiński j...@ask.me wrote:
string s = ;
assert(s); // ok
Actually I'm having a hard time understanding this:
void main()
{
string s = ;
assert(s); // pass, but why?
assert(s !is null); // pass
}
void main()
{
string s = .idup;
assert(s); // fail
assert(s !is null); // pass
}
On 12/12/10, Andrej Mitrovic andrej.mitrov...@gmail.com wrote:
The
On Saturday 11 December 2010 18:18:54 Tomek Sowiński wrote:
string s = ;
assert(s); // ok
assert(s != null); // fails
I guess that's a bug. But which one is right?
A null array and an empty array are essentially the same thing as far as D is
concerned. I believe that the only difference
Andrej Mitrovic andrej.mitrov...@gmail.com wrote:
Actually I'm having a hard time understanding this:
void main()
{
string s = ;
assert(s); // pass, but why?
assert(s !is null); // pass
}
void main()
{
string s = .idup;
assert(s); // fail
assert(s !is null); // pass
}
Try adding
Ellery Newcomer ellery-newco...@utulsa.edu wrote:
I forget, why are we supposed to use is instead of == with null?
'[] is null' compares ptr and length, while '[] == null' compares only
the length. Weirdly though, '[] is null' is false for ptr == 0,
length != 0. Not likely to happen much in
Simen kjaeraas simen.kja...@gmail.com wrote:
Ellery Newcomer ellery-newco...@utulsa.edu wrote:
I forget, why are we supposed to use is instead of == with null?
'[] is null' compares ptr and length, while '[] == null' compares only
the length. Weirdly though, '[] is null' is false for ptr ==
Jonathan M Davis jmdavisp...@gmx.com wrote:
This behavior is intended. Arrays are actually something like this under
the hood:
struct array(T)
{
T* arr;
size_t length;
}
Actually, that is:
struct array(T)
{
size_t length;
T* ptr;
}
To get the layout and names right.
(
On Saturday 11 December 2010 19:00:55 Jonathan M Davis wrote:
On Saturday 11 December 2010 18:18:54 Tomek Sowiński wrote:
string s = ;
assert(s); // ok
assert(s != null); // fails
I guess that's a bug. But which one is right?
A null array and an empty array are essentially the
On Saturday 11 December 2010 19:08:33 Simen kjaeraas wrote:
Jonathan M Davis jmdavisp...@gmx.com wrote:
This behavior is intended. Arrays are actually something like this under
the hood:
struct array(T)
{
T* arr;
size_t length;
}
Actually, that is:
struct
Coolio. I should pay a visit to druntime.. sometime. :)
On 12/12/10, Jonathan M Davis jmdavisp...@gmx.com wrote:
On Saturday 11 December 2010 19:00:55 Jonathan M Davis wrote:
On Saturday 11 December 2010 18:18:54 Tomek Sowiński wrote:
string s = ;
assert(s); // ok
assert(s != null); //
On Saturday 11 December 2010 19:16:29 Jonathan M Davis wrote:
On Saturday 11 December 2010 19:08:33 Simen kjaeraas wrote:
Jonathan M Davis jmdavisp...@gmx.com wrote:
This behavior is intended. Arrays are actually something like this
under the hood:
struct array(T)
{
15 matches
Mail list logo