Re: Return type of std.algorithm.map

2011-07-08 Thread James Fisher
OK, good replies. Cool. So the two places I thought I'd need to use explicit types are in parameter and return types. Say, a function returns the result of map, and another consumes it to print it. The consuming function seems to work with templating: void printSquares(T)(T squares) {

Re: Return type of std.algorithm.map

2011-07-08 Thread James Fisher
On Fri, Jul 8, 2011 at 4:06 PM, James Fisher jameshfis...@gmail.com wrote: So ... stuff works, but I'm not really sure why one uses function templating and the other uses return type inference. Any answers? ... Wait, brain malfunction; I think I do understand. The type is inferable purely

Re: Return type of std.algorithm.map

2011-07-08 Thread Steven Schveighoffer
On Fri, 08 Jul 2011 11:08:14 -0400, James Fisher jameshfis...@gmail.com wrote: On Fri, Jul 8, 2011 at 4:06 PM, James Fisher jameshfis...@gmail.com wrote: So ... stuff works, but I'm not really sure why one uses function templating and the other uses return type inference. Any answers?

Re: Return type of std.algorithm.map

2011-07-08 Thread James Fisher
On Fri, Jul 8, 2011 at 4:49 PM, Steven Schveighoffer schvei...@yahoo.comwrote: On Fri, 08 Jul 2011 11:08:14 -0400, James Fisher jameshfis...@gmail.com wrote: On Fri, Jul 8, 2011 at 4:06 PM, James Fisher jameshfis...@gmail.com wrote: So ... stuff works, but I'm not really sure why one

Return type of std.algorithm.map

2011-07-07 Thread James Fisher
To date, I've been using D in much the same way I used C++, without heavy use of templates. Now I'm trying out a more functional style using std.algorithm. However I'm pretty much stuck at the first hurdle: map. With type inference, this works: import std.algorithm; import std.stdio; void

Re: Return type of std.algorithm.map

2011-07-07 Thread Jonathan M Davis
On 2011-07-07 07:00, James Fisher wrote: To date, I've been using D in much the same way I used C++, without heavy use of templates. Now I'm trying out a more functional style using std.algorithm. However I'm pretty much stuck at the first hurdle: map. With type inference, this works:

Re: Return type of std.algorithm.map

2011-07-07 Thread bearophile
James Fisher: To date, I've been using D in much the same way I used C++, without heavy use of templates. Now I'm trying out a more functional style using std.algorithm. However I'm pretty much stuck at the first hurdle: map. Welcome to functional D :-) The most general interfaces I can

Re: Return type of std.algorithm.map

2011-07-07 Thread Steven Schveighoffer
On Thu, 07 Jul 2011 10:00:48 -0400, James Fisher jameshfis...@gmail.com wrote: To date, I've been using D in much the same way I used C++, without heavy use of templates. Now I'm trying out a more functional style using std.algorithm. However I'm pretty much stuck at the first hurdle: map.