Re: Request: a more logical static array behavior

2013-08-14 Thread Tommi
On Thursday, 15 August 2013 at 00:57:26 UTC, Tommi wrote: ... And half the time I say "converted to int[]" I mean "converted to uint[]" and the other half of the time I mean "converted to char[]". Sorry about that.

Re: Request: a more logical static array behavior

2013-08-14 Thread Tommi
On Thursday, 15 August 2013 at 01:05:54 UTC, Tommi wrote: On Thursday, 15 August 2013 at 00:57:26 UTC, Tommi wrote: ... And half the time I say "converted to int[]" I mean "converted to uint[]" and the other half of the time I mean "converted to char[]". Sorry about that. Actually that's n

Re: Request: a more logical static array behavior

2013-08-14 Thread Jonathan M Davis
On Thursday, August 15, 2013 02:57:25 Tommi wrote: > Thus, my point is this: > Shouldn't this magical property of static arrays (implicitly > converting to dynamic array during type deduction) extend to all > type deduction situations? No. If anything, we should get rid of the implicit conversion

Re: Request: a more logical static array behavior

2013-08-15 Thread Maxim Fomin
On Thursday, 15 August 2013 at 00:57:26 UTC, Tommi wrote: Static array types are somewhat magical in D; they can do something that no other non-subtype type can do: static arrays can implicitly convert to another type during type deduction. More specifically, e.g. int[3] can implicitly conver

Re: Request: a more logical static array behavior

2013-08-15 Thread monarch_dodra
On Thursday, 15 August 2013 at 02:30:54 UTC, Jonathan M Davis wrote: On Thursday, August 15, 2013 02:57:25 Tommi wrote: Thus, my point is this: Shouldn't this magical property of static arrays (implicitly converting to dynamic array during type deduction) extend to all type deduction situation

Re: Request: a more logical static array behavior

2013-08-15 Thread Tommi
On Thursday, 15 August 2013 at 02:30:54 UTC, Jonathan M Davis wrote: On Thursday, August 15, 2013 02:57:25 Tommi wrote: Thus, my point is this: Shouldn't this magical property of static arrays (implicitly converting to dynamic array during type deduction) extend to all type deduction situation

Re: Request: a more logical static array behavior

2013-08-15 Thread Dicebot
On Thursday, 15 August 2013 at 02:30:54 UTC, Jonathan M Davis wrote: No. If anything, we should get rid of the implicit conversion from a static array to a dynamic one. It's actually unsafe to do so. It's just like if you implicitly converted a local variable to the address of that local variab

Re: Request: a more logical static array behavior

2013-08-15 Thread Tommi
On Thursday, 15 August 2013 at 07:16:01 UTC, Maxim Fomin wrote: On Thursday, 15 August 2013 at 00:57:26 UTC, Tommi wrote: Static array types are somewhat magical in D; they can do something that no other non-subtype type can do: static arrays can implicitly convert to another type during type

Re: Request: a more logical static array behavior

2013-08-15 Thread Maxim Fomin
On Thursday, 15 August 2013 at 12:12:59 UTC, Tommi wrote: Implicit conversion VS Implicit conversion during type deduction I don't think that you failed to see the distinction between these two things, but because someone might, I

Re: Request: a more logical static array behavior

2013-08-15 Thread Artur Skawina
On 08/15/13 14:44, Tommi wrote: [...] > No, I'm not asking A -> C, I'm just asking that int[3] convert to int[]. >From you earlier post: Ret bar(R)(R r) // [6] if (std.range.isInputRange!R) { return Ret.input_range; } You'd like to be able to call 'bar' with a static array. Current

Re: Request: a more logical static array behavior

2013-08-15 Thread Maxim Fomin
On Thursday, 15 August 2013 at 12:44:09 UTC, Tommi wrote: I don't expect int[3] to implicitly convert to int[] during type deduction for the same reason that I don't expect int to implicitly convert to long during type deduction (even though I know that int implicitly converts to long in all

Re: Request: a more logical static array behavior

2013-08-15 Thread Tommi
On Thursday, 15 August 2013 at 13:25:58 UTC, Maxim Fomin wrote: On Thursday, 15 August 2013 at 12:12:59 UTC, Tommi wrote: Implicit conversion VS Implicit conversion during type deduction I don't think that you failed to see the

Re: Request: a more logical static array behavior

2013-08-15 Thread Tommi
On Thursday, 15 August 2013 at 13:50:45 UTC, Maxim Fomin wrote: On Thursday, 15 August 2013 at 12:44:09 UTC, Tommi wrote: I don't expect int[3] to implicitly convert to int[] during type deduction for the same reason that I don't expect int to implicitly convert to long during type deduction

Re: Request: a more logical static array behavior

2013-08-15 Thread Tommi
On Thursday, 15 August 2013 at 13:53:17 UTC, Artur Skawina wrote: On 08/15/13 14:44, Tommi wrote: [...] No, I'm not asking A -> C, I'm just asking that int[3] convert to int[]. From you earlier post: Ret bar(R)(R r) // [6] if (std.range.isInputRange!R) { return Ret.input_range;

Re: Request: a more logical static array behavior

2013-08-15 Thread Maxim Fomin
On Thursday, 15 August 2013 at 14:32:29 UTC, Tommi wrote: No it's not: void getLong(T)(T arg) if (is(T : long)) { static assert(is(typeof(arg) == int)); } void main() { int n; getLong(n); // int is _not_ implicitly converted to long } Yes, because during type deduction there was

Re: Request: a more logical static array behavior

2013-08-15 Thread Tommi
On Thursday, 15 August 2013 at 14:53:08 UTC, Maxim Fomin wrote: On Thursday, 15 August 2013 at 14:32:29 UTC, Tommi wrote: No it's not: void getLong(T)(T arg) if (is(T : long)) { static assert(is(typeof(arg) == int)); } void main() { int n; getLong(n); // int is _not_ implicitly conve

Re: Request: a more logical static array behavior

2013-08-15 Thread Tommi
On Thursday, 15 August 2013 at 15:07:23 UTC, Tommi wrote: The only time when the compiler is willing to consider the possible implicit conversions during type deduction is with static arrays: hence... "magic". Barring this special case which I mentioned in my original post: On Thursday, 15 Au