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

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,

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 10 October 2015 at 16:19:53 UTC, Nordlöw wrote: Is there an algorithm somewhere in Phobos which performs when possible a replacement/substitution based on a variadic definition of replacements using hash-table search similar to Found it:

Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
Is there an algorithm somewhere in Phobos which performs when possible a replacement/substitution based on a variadic definition of replacements using hash-table search similar to string replaceWhole(string a) { switch (x) { case "a": return "1"; case "b": return "2";

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

Re: AWS API Dlang, hmac sha256 function.

2015-10-10 Thread holo via Digitalmars-d-learn
On Friday, 9 October 2015 at 16:30:26 UTC, holo wrote: OK i find out error, in addRequestHeader i was using ":" after header name what casing problem. I removed it and now im getting "unauthorized". Here is how it looks right now: HTTP/1.1 401 Unauthorized\r\n [Expert Info

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 10 October 2015 at 16:42:52 UTC, Nordlöw wrote: Found it: http://dlang.org/phobos/std_algorithm_comparison.html#predSwitch An alias would be perhaps be motivated to make newcomers easier grap that this can be used for whole replacements. Ahh, but this doesn't use a hash-table

Compile time and runtime grammars

2015-10-10 Thread DLangLearner via Digitalmars-d-learn
Only now I found that most of my confusions are with D's compile time grammar or features. As an excuse, my confusions can be partially attributed to the way D is presented: 1. There are confusing keywords: For example, there is a "if", there is also a "static if", there is a "if", and there

Re: Compile time and runtime grammars

2015-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 10, 2015 at 06:52:29PM +, DLangLearner via Digitalmars-d-learn wrote: > Only now I found that most of my confusions are with D's compile time > grammar or features. As an excuse, my confusions can be partially > attributed to the way D is presented: > > 1. There are confusing

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

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Meta via Digitalmars-d-learn
On Saturday, 10 October 2015 at 16:19:53 UTC, Nordlöw wrote: Is there an algorithm somewhere in Phobos which performs when possible a replacement/substitution based on a variadic definition of replacements using hash-table search similar to string replaceWhole(string a) { switch (x) {

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.

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.

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 11 October 2015 at 00:16:44 UTC, Meta wrote: There was something like this proposed quite awhile ago (can't remember what it was, might've been extending unary/binaryFun to accept an AA), but it was rejected. With static foreach in a switch we can do better. I'll put together a

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

Re: Compile time and runtime grammars

2015-10-10 Thread Ali Çehreli via Digitalmars-d-learn
On 10/10/2015 12:43 PM, H. S. Teoh via Digitalmars-d-learn wrote: > On Sat, Oct 10, 2015 at 06:52:29PM +, DLangLearner via Digitalmars-d-learn wrote: >> 1. There are confusing keywords: To OP: I am glad that you are not bothered with compile-time foreach. ;) > The "static" in "static if"