rfc:clamp
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:clamp [2021/06/23 18:29] – created thinkverse | rfc:clamp [2021/07/08 10:49] – Update proposed version to PHP 8.2 thinkverse | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Author: Kim Hallberg, hallbergkim@gmail.com | * Author: Kim Hallberg, hallbergkim@gmail.com | ||
* Status: Under Discussion | * Status: Under Discussion | ||
- | * Proposed Version: PHP 8.1 | + | * Proposed Version: PHP 8.2 |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | '' | + | '' |
Current userland implementations are handled in several ways, some of which use [[https:// | Current userland implementations are handled in several ways, some of which use [[https:// | ||
Line 20: | Line 20: | ||
</ | </ | ||
- | '' | + | '' |
If '' | If '' | ||
Line 27: | Line 27: | ||
<code php> | <code php> | ||
- | clamp(num: 1, min: 0, max: 3); // 1 inbound | + | clamp(num: 1, min: 0, max: 3); // 1 in range |
clamp(num: 1, min: 2, max: 5); // 2 < bound | clamp(num: 1, min: 2, max: 5); // 2 < bound | ||
clamp(num: 4, min: 1, max: 3); // 3 > bound | clamp(num: 4, min: 1, max: 3); // 3 > bound | ||
Line 33: | Line 33: | ||
clamp(num: 0, min: 2, max: 1); // clamp(): Argument #2 ($min) cannot be greater than Argument #3 ($max) | clamp(num: 0, min: 2, max: 1); // clamp(): Argument #2 ($min) cannot be greater than Argument #3 ($max) | ||
</ | </ | ||
+ | |||
+ | Handling NAN; passing NAN to either of the range values will throw above '' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 54: | Line 56: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | No open issues as of yet. | + | 1) Handling |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
Line 72: | Line 74: | ||
* Implementation PR: [[https:// | * Implementation PR: [[https:// | ||
* Discussion on the php.internals mailing list: [[https:// | * Discussion on the php.internals mailing list: [[https:// | ||
+ | * Announcement thread: [[https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
No rejected features currently. | No rejected features currently. |
rfc/clamp.txt · Last modified: 2023/06/12 13:59 by thinkverse