[Issue 10039] std.algorithm enhancements: min, max, clamp

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 18 03:24:12 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10039


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #7 from monarchdodra at 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: -------


More information about the Digitalmars-d-bugs mailing list