Skip to content
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

Add clamp(x, T) #34426

Merged
merged 1 commit into from
Jan 19, 2020
Merged

Add clamp(x, T) #34426

merged 1 commit into from
Jan 19, 2020

Conversation

Keno
Copy link
Member

@Keno Keno commented Jan 17, 2020

This is #22235, but with the reversed argument order.

julia> clamp( 260, UInt8 )
0xff

Co-authored-by: "arghhhh [email protected]"

This is #22235, but with the reversed argument order.
```
julia> clamp( 260, UInt8 )
0xff
```

Co-authored-by: "arghhhh <[email protected]>"
@JeffBezanson
Copy link
Member

A difficult argument order situation, but I think I agree. My explanation would be that functions primarily about converting between types (convert, trunc, ...) put the type first, but other functions where a type stands in for numbers, ranges, etc. leave the argument in its natural position (clamp, %, ...).

@Keno
Copy link
Member Author

Keno commented Jan 19, 2020

Yes, I think the genericness argument wins here. E.g. if we wanted to clamp to some interval I in a package that method should be clamp(x, I). Merging.

@Keno Keno merged commit 5bed770 into master Jan 19, 2020
@Keno Keno deleted the kf/clamp branch January 19, 2020 02:40
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
This is #22235, but with the reversed argument order.
```
julia> clamp( 260, UInt8 )
0xff
```

Co-authored-by: "arghhhh <[email protected]>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants