Re: How to check whether an empty array variable is null?

2015-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 11, 2015 05:10:34 tcak via Digitalmars-d-learn wrote: > On Saturday, 10 October 2015 at 20:07:11 UTC, Jonathan M Davis > wrote: > > On Saturday, October 10, 2015 15:20:02 tcak via > > Digitalmars-d-learn wrote: > >> [code] > >> int[] list; > >> > >> list = new int[0]; > >> >

Re: How to check whether an empty array variable is null?

2015-10-11 Thread Ozan via Digitalmars-d-learn
On Saturday, 10 October 2015 at 15:46:51 UTC, Meta wrote: On Saturday, 10 October 2015 at 15:20:04 UTC, tcak wrote: [code] int[] list; list = new int[0]; std.stdio.writeln("Is Null ? ", (list is null)); [/code] Result is "Is Null? true". } Do I miss the point

Re: How to check whether an empty array variable is null?

2015-10-10 Thread tcak via Digitalmars-d-learn
On Saturday, 10 October 2015 at 20:07:11 UTC, Jonathan M Davis wrote: On Saturday, October 10, 2015 15:20:02 tcak via Digitalmars-d-learn wrote: [code] int[] list; list = new int[0]; std.stdio.writeln("Is Null ? ", (list is null)); [/code] Result is "Is Null? true". Is this the correct

Re: How to check whether an empty array variable is null?

2015-10-10 Thread Meta via Digitalmars-d-learn
On Sunday, 11 October 2015 at 00:18:54 UTC, Meta wrote: On Saturday, 10 October 2015 at 20:07:11 UTC, Jonathan M Davis wrote: It basically didn't bother to allocate an array on the heap, because you asked for one with a length of zero. Efficiency-wise, it makes no sense to allocate anything. Yo

Re: How to check whether an empty array variable is null?

2015-10-10 Thread Meta via Digitalmars-d-learn
On Saturday, 10 October 2015 at 20:07:11 UTC, Jonathan M Davis wrote: It basically didn't bother to allocate an array on the heap, because you asked for one with a length of zero. Efficiency-wise, it makes no sense to allocate anything. You wouldn't be doing anything with the memory anyway. The

Re: How to check whether an empty array variable is null?

2015-10-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 10, 2015 15:20:02 tcak via Digitalmars-d-learn wrote: > [code] > int[] list; > > list = new int[0]; > > std.stdio.writeln("Is Null ? ", (list is null)); > [/code] > > Result is "Is Null? true". > > Is this the correct behaviour? I would expect compiler to point > to an ad

Re: How to check whether an empty array variable is null?

2015-10-10 Thread Meta via Digitalmars-d-learn
On Saturday, 10 October 2015 at 15:20:04 UTC, tcak wrote: [code] int[] list; list = new int[0]; std.stdio.writeln("Is Null ? ", (list is null)); [/code] Result is "Is Null? true". Is this the correct behaviour? I would expect compiler to point to an address in the hea

Re: How to check whether an empty array variable is null?

2015-10-10 Thread rumbu via Digitalmars-d-learn
On Saturday, 10 October 2015 at 15:20:04 UTC, tcak wrote: [code] int[] list; list = new int[0]; std.stdio.writeln("Is Null ? ", (list is null)); [/code] Result is "Is Null? true". Is this the correct behaviour? I would expect compiler to point to an address in the hea

How to check whether an empty array variable is null?

2015-10-10 Thread tcak via Digitalmars-d-learn
[code] int[] list; list = new int[0]; std.stdio.writeln("Is Null ? ", (list is null)); [/code] Result is "Is Null? true". Is this the correct behaviour? I would expect compiler to point to an address in the heap, but set the length as 0. So, it wouldn't return null, b