Re: Compiler fails to match array literal to byte[] in templated functions (Was: Re: More putrid beef soup (Was: Re: Implicit string lit conversion) to wstring/dstring)

2012-03-19 Thread Timon Gehr
On 03/19/2012 04:40 AM, H. S. Teoh wrote: OK, perhaps the previous subject line of the previous post deterred people from actually reading the contents. :-( Basically, I'm trying to address Andrei's request that this should work with my AA implementation: int[dstring] aa;

Compiler fails to match array literal to byte[] in templated functions (Was: Re: More putrid beef soup (Was: Re: Implicit string lit conversion) to wstring/dstring)

2012-03-18 Thread H. S. Teoh
OK, perhaps the previous subject line of the previous post deterred people from actually reading the contents. :-( Basically, I'm trying to address Andrei's request that this should work with my AA implementation: int[dstring] aa; aa[abc] = 1; // abc implicitly deduced as

Re: Compiler fails to match array literal to byte[] in templated functions (Was: Re: More putrid beef soup (Was: Re: Implicit string lit conversion) to wstring/dstring)

2012-03-18 Thread James Miller
On 19 March 2012 16:40, H. S. Teoh hst...@quickfur.ath.cx wrote: OK, perhaps the previous subject line of the previous post deterred people from actually reading the contents. :-( Basically, I'm trying to address Andrei's request that this should work with my AA implementation:        

More putrid beef soup (Was: Re: Implicit string lit conversion to wstring/dstring)

2012-03-17 Thread H. S. Teoh
On Wed, Mar 14, 2012 at 02:07:04PM -0500, Andrei Alexandrescu wrote: [...] Aha! This is one of those cases in which built-in magic smells of putrid beef soup. [...] It gets worse than we first thought: void f1(dstring x) { dstring y = x; } void f2()(dstring x) { dstring y = x;

Implicit string lit conversion to wstring/dstring

2012-03-14 Thread H. S. Teoh
Code: import std.stdio; version(explicit) { void func(dstring s) { dstring t = s; writeln(t); } } else { void func(S)(S s) { dstring t = s; // line 10

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Alex Rønne Petersen
On 14-03-2012 19:00, H. S. Teoh wrote: Code: import std.stdio; version(explicit) { void func(dstring s) { dstring t = s; writeln(t); } } else { void func(S)(S s) {

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Alex Rønne Petersen
On 14-03-2012 19:00, Alex Rønne Petersen wrote: On 14-03-2012 19:00, H. S. Teoh wrote: Code: import std.stdio; version(explicit) { void func(dstring s) { dstring t = s; writeln(t); } } else { void func(S)(S s) { dstring t = s; // line 10 writeln(t); } } void main() { func(abc); } If

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread H. S. Teoh
On Wed, Mar 14, 2012 at 07:00:35PM +0100, Alex Rønne Petersen wrote: On 14-03-2012 19:00, H. S. Teoh wrote: Code: import std.stdio; version(explicit) { void func(dstring s) { dstring t = s; writeln(t); } }

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Alex Rønne Petersen
On 14-03-2012 19:16, H. S. Teoh wrote: On Wed, Mar 14, 2012 at 07:00:35PM +0100, Alex Rønne Petersen wrote: On 14-03-2012 19:00, H. S. Teoh wrote: Code: import std.stdio; version(explicit) { void func(dstring s) { dstring t = s;

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Dmitry Olshansky
On 14.03.2012 22:00, H. S. Teoh wrote: Code: import std.stdio; version(explicit) { void func(dstring s) { dstring t = s; writeln(t); } } else { void func(S)(S s) {

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Nick Sabalausky
Alex Rønne Petersen xtzgzo...@gmail.com wrote in message news:jjqn9f$1iht$1...@digitalmars.com... But then... why not just make it take a dstring? Maybe I'm not following your intent here... Probably because then this becomes an error: string s = abc; func(s); It's an interesting problem.

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Nick Sabalausky
Dmitry Olshansky dmitry.o...@gmail.com wrote in message news:jjqnnj$1j86$1...@digitalmars.com... How about this (untested)? void func()(dstring s) { dstring t = s; //... funcImpl(t); } void func(S)(S s) { dstring t = to!dstring(s); //... funcImpl(t); } That fails to compile when

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Steven Schveighoffer
On Wed, 14 Mar 2012 14:16:11 -0400, H. S. Teoh hst...@quickfur.ath.cx wrote: What I want is to force the compiler to deduce S=dstring when I declare func(S)(S) and call it as func(abc). http://d.puremagic.com/issues/show_bug.cgi?id=4998 Please vote or contribute your thoughts. -Steve

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread H. S. Teoh
On Wed, Mar 14, 2012 at 02:44:40PM -0400, Steven Schveighoffer wrote: On Wed, 14 Mar 2012 14:16:11 -0400, H. S. Teoh hst...@quickfur.ath.cx wrote: What I want is to force the compiler to deduce S=dstring when I declare func(S)(S) and call it as func(abc).

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Andrei Alexandrescu
On 3/14/12 2:01 PM, H. S. Teoh wrote: However, this change broke this code: AssociativeArray!(wstring,int) aa; aa[abc] = 123; // error: compiler deduces K as string, // so isCompatWithKey!K fails: string //

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread H. S. Teoh
On Wed, Mar 14, 2012 at 02:07:04PM -0500, Andrei Alexandrescu wrote: On 3/14/12 2:01 PM, H. S. Teoh wrote: However, this change broke this code: AssociativeArray!(wstring,int) aa; aa[abc] = 123;// error: compiler deduces K as string, // so

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread H. S. Teoh
On Wed, Mar 14, 2012 at 02:07:04PM -0500, Andrei Alexandrescu wrote: On 3/14/12 2:01 PM, H. S. Teoh wrote: However, this change broke this code: AssociativeArray!(wstring,int) aa; aa[abc] = 123;// error: compiler deduces K as string, // so

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Andrei Alexandrescu
On 3/14/12 2:34 PM, H. S. Teoh wrote: I tried the following, but it still doesn't work properly: void opIndexAssign()(in Value v, in Key key) { __opIndexAssignImpl(v, key); } void opIndexAssign(K)(in Value v, in K key) if

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Timon Gehr
On 03/14/2012 08:34 PM, H. S. Teoh wrote: On Wed, Mar 14, 2012 at 02:07:04PM -0500, Andrei Alexandrescu wrote: On 3/14/12 2:01 PM, H. S. Teoh wrote: However, this change broke this code: AssociativeArray!(wstring,int) aa; aa[abc] = 123; // error: compiler deduces K as

Re: Implicit string lit conversion to wstring/dstring

2012-03-14 Thread Timon Gehr
On 03/14/2012 09:18 PM, Timon Gehr wrote: Use this for now: void opIndexAssign(K)(in int v, scope K key) if (!is(K==Key) isCompatWithKey!K) {...} oops. I meant: void opIndexAssign(K)(in Value v, scope K key) if (!is(K==Key) isCompatWithKey!K) {...} 'in K key'/const(K) key will only