Summary: map! needs to fail on void functions + I'd like a
                    mapCall function
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from Andrej Mitrovic <> 2011-03-31 
18:57:51 PDT ---
import std.stdio;
import std.algorithm;

void mapCall(alias func, T)(T t)
    foreach (value; t)

void main()
    // nothing happens
    map!(writeln)([4, 5, 6]);   

    // prints 4\n, 5\n, 6\n
    mapCall!(writeln)(4, 5, 6);

map doesn't work properly with void functions, it should at least check the
return type of a function and fail to instantiate if the return type is void.
Otherwise it seems like this is a no-op since nothing really happens.

The feature request is to either expand map! to work on void functions, or
introduce a new function which allows us to call a single function in sequence
with various arguments. The `mapCall` implementation here is just a
demonstration, as is its name.

I think this type of function could be a useful to have, unless something like
this already exists in Phobos (well, map was supposed to be it but it doesn't
work for void functions..).

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to