[Issue 10039] std.algorithm enhancements: min, max, clamp
https://issues.dlang.org/show_bug.cgi?id=10039 Basile-z changed: What|Removed |Added CC|b2.t...@gmx.com | --
[Issue 10039] std.algorithm enhancements: min, max, clamp
https://issues.dlang.org/show_bug.cgi?id=10039 bb.t...@gmx.com changed: What|Removed |Added Status|NEW |RESOLVED CC||bb.t...@gmx.com Resolution|--- |FIXED --- Comment #12 from bb.t...@gmx.com --- min(), max() & clamp() are all in std.algorithm.comparison now. --
[Issue 10039] std.algorithm enhancements: min, max, clamp
https://issues.dlang.org/show_bug.cgi?id=10039 --- Comment #11 from github-bugzi...@puremagic.com --- Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/5cde6f5fd56e38b093a7aa39e1fcfec65554 Add clamp function Request in issue 10039 http://d.puremagic.com/issues/show_bug.cgi?id=10039 --
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 monarchdo...@gmail.com changed: What|Removed |Added CC||monarchdo...@gmail.com --- Comment #7 from monarchdo...@gmail.com 2013-08-18 03:24:05 PDT --- (In reply to comment #0) Since min/max are supposed to be variadic they should also accept a single parameter. min(var) == var max(var) == var I did a pull to allow this, but I bailed out. While most of the time, I agree with such improvements, in this particular case, the names min and max are problematic, due to clashes with the built in .min and .max properties. In particular, it means you can now write: 5.max(); //This resolves to 5 which is different from: 5.max; //This resolves to int.max I think that making it so that (accidentally) adding parenthesis to 5.min actually compiles, yet has a different meaning, is too dangerous for what it buys us. TLDR: I think this allowing single arg min/max is a bad idea. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 --- Comment #8 from bearophile_h...@eml.cc 2013-08-18 05:36:59 PDT --- (In reply to comment #7) TLDR: I think this allowing single arg min/max is a bad idea. I agree. Let's close WONTFIX this issue? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 --- Comment #9 from monarchdo...@gmail.com 2013-08-18 05:50:57 PDT --- (In reply to comment #8) (In reply to comment #7) TLDR: I think this allowing single arg min/max is a bad idea. I agree. Let's close WONTFIX this issue? Unfortunately, this is a dual entry entry. Let's just say that min/max is being closed as WONTFIX by this present comment. The issue is still open though, as campl is a valid request, and there is already an open pull for it referencing this entry: https://github.com/D-Programming-Language/phobos/pull/1360 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 yebblies yebbl...@gmail.com changed: What|Removed |Added CC||yebbl...@gmail.com --- Comment #6 from yebblies yebbl...@gmail.com 2013-08-03 14:36:04 EST --- (In reply to comment #5) (In reply to comment #4) The single parameter cases come up when using min/max in generic code. Otherwise it is necessary to special case it on every use. Can you show one real example of such generic code where this happens? import std.algorithm; import std.stdio; int minpos(T...)(T args) { auto minv = min(args); foreach(i, v; args) if (v == minv) return i; return -1; } void main() { writeln(minpos(3, 2, 1)); writeln(minpos(2, 1)); writeln(minpos(1)); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 q...@web.de changed: What|Removed |Added CC||q...@web.de --- Comment #1 from q...@web.de 2013-06-21 06:50:29 PDT --- How does that unary min/max variant come up? With regard to clamp, there is also the question if it can/should be variadic? clamp(a,b,c,d) =?= max(a,min(b,max(c,d))) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 --- Comment #2 from q...@web.de 2013-06-21 07:05:55 PDT --- Pull request for clamp: https://github.com/D-Programming-Language/phobos/pull/1360 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 bearophile_h...@eml.cc changed: What|Removed |Added CC||bearophile_h...@eml.cc --- Comment #3 from bearophile_h...@eml.cc 2013-06-21 09:31:35 PDT --- Regarding max(x) and min(x) what are the use cases? I don't see any. Regarding clamp(), sometimes I need a function like that. But I think it's better to design it like this: clamp(var, a, b) so it's usable in UFCS chains. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 --- Comment #4 from Diggory digg...@googlemail.com 2013-06-21 14:12:30 PDT --- (In reply to comment #3) Regarding max(x) and min(x) what are the use cases? I don't see any. Regarding clamp(), sometimes I need a function like that. But I think it's better to design it like this: clamp(var, a, b) so it's usable in UFCS chains. The single parameter cases come up when using min/max in generic code. Otherwise it is necessary to special case it on every use. With regards to clamp I have no strong feelings about parameter order, etc. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 10039] std.algorithm enhancements: min, max, clamp
http://d.puremagic.com/issues/show_bug.cgi?id=10039 --- Comment #5 from bearophile_h...@eml.cc 2013-06-21 14:50:15 PDT --- (In reply to comment #4) The single parameter cases come up when using min/max in generic code. Otherwise it is necessary to special case it on every use. Can you show one real example of such generic code where this happens? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---