Re: how convert the range to slice ?

2016-06-09 Thread Nordlöw via Digitalmars-d-learn
On Monday, 2 February 2015 at 21:04:11 UTC, Nordlöw wrote: Made it PR at https://github.com/D-Programming-Language/dmd/pull/4371 Synched with DMD D conversion and improved isInputRange and message at: https://github.com/dlang/dmd/pull/4371

Re: how convert the range to slice ?

2015-02-02 Thread Nordlöw
On Monday, 2 February 2015 at 19:04:52 UTC, Nordlöw wrote: https://github.com/nordlow/dmd/commit/40ce0ecf34f90c4d3053c47e9286d7574f596e15 Made it PR at https://github.com/D-Programming-Language/dmd/pull/4371

Re: how convert the range to slice ?

2015-02-02 Thread bearophile via Digitalmars-d-learn
Nordlöw: Is started digging a bit... The magic happens at line 103 in cast.c. How do I most conveniently figure out which members (functions) a type (e-type) has? I figured I could check for typical InputRange members and issue a hint about using .array if e-type has them. It's probably

Re: how convert the range to slice ?

2015-02-02 Thread Nordlöw
On Monday, 2 February 2015 at 16:56:02 UTC, bearophile wrote: Nordlöw: Is started digging a bit... The magic happens at line 103 in cast.c. How do I most conveniently figure out which members (functions) a type (e-type) has? I figured I could check for typical InputRange members and

Re: how convert the range to slice ?

2015-02-01 Thread Nordlöw
On Wednesday, 28 January 2015 at 23:21:34 UTC, Nordlöw wrote: I'll dig into it later on... Is started digging a bit... The magic happens at line 103 in cast.c. How do I most conveniently figure out which members (functions) a type (e-type) has? I figured I could check for typical

how convert the range to slice ?

2015-01-28 Thread mzfhhhh via Digitalmars-d-learn
is there any simple way to convert? int [] arr1 = [1,2,3].map!a*2; //compile error int [] arr2 = [1,2,3].filter!a3;//compile error

Re: how convert the range to slice ?

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 23:15:32 UTC, bearophile wrote: I think you can try to open a diagnostic enhancement request. Nice, that's what I'd hoped for you'd say :) I'll dig into it later on...

Re: how convert the range to slice ?

2015-01-28 Thread bearophile via Digitalmars-d-learn
Chris Williams: Range is not castable to array. See std.array.array to generate an array from a Range. Currently this program: void main() { import std.range; int[] a = iota(10); } Gives an error like: test.d(3,19): Error: cannot implicitly convert expression (iota(10)) of type

Re: how convert the range to slice ?

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 22:43:36 UTC, bearophile wrote: It's such a fundamental part of D+Phobos that newbies are forced to learn this quickly. On the other hand an informative error message could be useful... What error message do you suggest? Something like: ..., expression

Re: how convert the range to slice ?

2015-01-28 Thread data man via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:32:38 UTC, mzf wrote: is there any simple way to convert? int [] arr1 = [1,2,3].map!a*2; //compile error int [] arr2 = [1,2,3].filter!a3;//compile error auto arr1 = [1,2,3].map!a*2.array; auto arr2 = [1,2,3].filter!a3.array;

Re: how convert the range to slice ?

2015-01-28 Thread bearophile via Digitalmars-d-learn
Nordlöw: Is there any chance we could add logic to dmd+phobos that hints user about this? It's such a fundamental part of D+Phobos that newbies are forced to learn this quickly. On the other hand an informative error message could be useful... What error message do you suggest? Bye,

Re: how convert the range to slice ?

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 14:54:27 UTC, data man wrote: auto arr1 = [1,2,3].map!a*2.array; auto arr2 = [1,2,3].filter!a3.array; Is there any chance we could add logic to dmd+phobos that hints user about this?

Re: how convert the range to slice ?

2015-01-28 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 22:43:36 UTC, bearophile wrote: Nordlöw: Is there any chance we could add logic to dmd+phobos that hints user about this? It's such a fundamental part of D+Phobos that newbies are forced to learn this quickly. On the other hand an informative error message