digitalmars.D.bugs - [Issue 5804] New: map! needs to fail on void functions + I'd like a mapCall function
- d-bugmail puremagic.com (43/43) Mar 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5804
- d-bugmail puremagic.com (10/10) Apr 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5804
- d-bugmail puremagic.com (13/13) Apr 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5804
- d-bugmail puremagic.com (15/15) Apr 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5804
- d-bugmail puremagic.com (7/8) Apr 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5804
- d-bugmail puremagic.com (11/11) Apr 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5804
http://d.puremagic.com/issues/show_bug.cgi?id=5804 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 AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2011-03-31 18:57:51 PDT --- import std.stdio; import std.algorithm; void mapCall(alias func, T)(T t) { foreach (value; t) { func(value); } } 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 31 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5804 Vladimir <thecybershadow gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow gmail.com --- Comment #1 from Vladimir <thecybershadow gmail.com> 2011-04-01 01:23:15 PDT --- Looks like a duplicate of issue 5753. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 01 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5804 Pedro Rodrigues <pdfrodrigues gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pdfrodrigues gmail.com --- Comment #2 from Pedro Rodrigues <pdfrodrigues gmail.com> 2011-04-24 06:02:19 PDT --- Void functions imply side effects. According to the documentation map! does lazy evaluation. In my experience, mixing up lazy evaluation with side effects should be avoided at all costs. That's why I think that map! should be used with pure functions only and reject promptly void functions. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 24 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5804 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #3 from bearophile_hugs eml.cc 2011-04-24 06:52:30 PDT --- I suggest to merge this with bug 5753 , or the other way around. Now pure functions are allowed to have a debug{} that contains impure code (for debug prints only, please), this decreases a little the need for impure functions. In bug 5756 I have asked for eager amap()/afilter(), that's more fit for an impure mapping function. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 24 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5804 --- Comment #4 from Pedro Rodrigues <pdfrodrigues gmail.com> 2011-04-24 12:26:24 PDT --- (In reply to comment #3)I suggest to merge this with bug 5753 , or the other way around.I agree. I proposed a fix in issue 5753. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 24 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5804 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2011-04-24 12:31:29 PDT --- *** This issue has been marked as a duplicate of issue 5753 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 24 2011