-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
min/max <?
/ >?
expressions
#20624
Comments
#20626 ...just trying it on! |
Maybe it's because I don't worship at the altar of C++, but I don't see how these messes of random punctuation are more readable than the status quo. |
Suggesting that |
I feel like you didn't read my post, either. |
The question mark because it's short-hand for the
You don't need to repeat |
This bugs me every few weeks for decades... I still want this just as much as the first say it ever came up for me:
It's really annoying to import a module for
min
/max
, it feels so 'heavy' for such a trivial operation. It's also annoying that they're functions; you have to step-in/step-out etc while debugging code, and they are so frequently used in hot-loops, while calling functions in debug/unoptimised code just slows it down needlessly, even more than unoptimised code already it...C++ has a non-standard language extension, and I think it's also present in C# that adds a min/max operator. It is this:
a <? b
anda >? b
, which simply expandsa < b ? a : b
anda > b ? a : b
.I desperately want these in D... they're just so nice and readable, don't require bulky imports, efficient in debug builds, nicer when working in the debugger, etc...
I know these are all minor nuisances, but the practical result is that I very rarely actually import
min
/max
, and almost always just write the expression outa < b ? a : b
, which damages code readability, particularly whena
orb
are long-ish expressions.This could be implemented with trivial lowering. It's lame when other languages have nice QOL features that we don't have in D, especially like this which are just cosmetic and pose no threats.
The text was updated successfully, but these errors were encountered: