Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-07 Thread Meta via Digitalmars-d
Something H.S. Teoh in a recent pull request in Github got me thinking that it would be useful in some cases to tell the compiler that you want to automatically infer the either the key type or value type of an AA. Something like the following: //typeof(aa) -> string[int] string[auto] aa = [1:

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-07 Thread Meta via Digitalmars-d
On Thursday, 7 August 2014 at 16:07:38 UTC, Meta wrote: Something H.S. Teoh in a recent pull request Something H.S. Teoh *said* in a recent pull request

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-07 Thread Daniel Murphy via Digitalmars-d
"Meta" wrote in message news:ohzzgcslkthrozimf...@forum.dlang.org... Something H.S. Teoh in a recent pull request in Github got me thinking that it would be useful in some cases to tell the compiler that you want to automatically infer the either the key type or value type of an AA. Something

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-07 Thread Meta via Digitalmars-d
On Thursday, 7 August 2014 at 17:37:54 UTC, Daniel Murphy wrote: "Meta" wrote in message news:ohzzgcslkthrozimf...@forum.dlang.org... Something H.S. Teoh in a recent pull request in Github got me thinking that it would be useful in some cases to tell the compiler that you want to automatical

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-08 Thread Daniel Murphy via Digitalmars-d
"Meta" wrote in message news:uvtdfndzaiamyvtkb...@forum.dlang.org... Isn't that also the case for the auto*, const[], immutable[$], etc. syntax? Conceptually it feels the same to me as Kenji's enhancement; I don't know enough about the compiler to talk about it technically. Yes, I have the

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-14 Thread bearophile via Digitalmars-d
Meta: Isn't that also the case for the auto*, const[], immutable[$], etc. syntax? Conceptually it feels the same to me as Kenji's enhancement; I don't know enough about the compiler to talk about it technically. One difference between Kenji's enhancement and the AA type inference is that ar

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-14 Thread Meta via Digitalmars-d
On Thursday, 14 August 2014 at 18:07:57 UTC, bearophile wrote: Meta: Isn't that also the case for the auto*, const[], immutable[$], etc. syntax? Conceptually it feels the same to me as Kenji's enhancement; I don't know enough about the compiler to talk about it technically. One difference b

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-15 Thread Kenji Hara via Digitalmars-d
I implemented partial type deduction in AA keys. https://github.com/D-Programming-Language/dmd/pull/3615 For example: auto[auto[$]] aa5 = [[1,2]:1, [3,4]:2]; static assert(is(typeof(aa5) == int[int[2]])); int[int[][$]] aa15 = [[[1],[2]]:1, [[3],[4]]:2]; static assert(is(typeof(aa1

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-15 Thread bearophile via Digitalmars-d
Kenji Hara: I implemented partial type deduction in AA keys. https://github.com/D-Programming-Language/dmd/pull/3615 For example: auto[auto[$]] aa5 = [[1,2]:1, [3,4]:2]; static assert(is(typeof(aa5) == int[int[2]])); int[int[][$]] aa15 = [[[1],[2]]:1, [[3],[4]]:2]; static asser

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-15 Thread Philippe Sigaud via Digitalmars-d
Kenji Hara: > I implemented partial type deduction in AA keys. > https://github.com/D-Programming-Language/dmd/pull/3615 > > For example: > auto[auto[$]] aa5 = [[1,2]:1, [3,4]:2]; > static assert(is(typeof(aa5) == int[int[2]])); > > int[int[][$]] aa15 = [[[1],[2]]:1, [[3],[4]]:2]; >

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-15 Thread Meta via Digitalmars-d
On Friday, 15 August 2014 at 08:34:22 UTC, Kenji Hara via Digitalmars-d wrote: I implemented partial type deduction in AA keys. https://github.com/D-Programming-Language/dmd/pull/3615 For example: auto[auto[$]] aa5 = [[1,2]:1, [3,4]:2]; static assert(is(typeof(aa5) == int[int[2]]));