> On 2 Sep 2016, at 06:14, Xiaodi Wu wrote:
>
> Run loop modes are named by string, and as you can see in your link,
> comparisons of run loop modes are by their raw value--i.e. by string. While
> it's of course sensible to have a total ordering for strings, I'm skeptical
> that you would typ
Run loop modes are named by string, and as you can see in your link,
comparisons of run loop modes are by their raw value--i.e. by string. While
it's of course sensible to have a total ordering for strings, I'm skeptical
that you would typically want to get the "maximum" of two strings, and I'm
not
> On 31 Aug 2016, at 15:53, Xiaodi Wu wrote:
>
> Comparable makes semantic guarantees about how values of conforming types
> might be ordered. You don't need `min` or `max` for that to be useful, since
> it's trivial to implement using comparison operators.
>
> Basic numeric types require com
I agree with karl. there is nothing really mathematical with min/max
e.g. find the longest sequence of characters in a string or the smallest array
or the minimal x coordinate of view objects…
min/max/clamp are needed everywhere.
LG
Dominik
Web: https://pich.info
Twitter: @DaijDjan
Facebook: Do
Comparable makes semantic guarantees about how values of conforming types
might be ordered. You don't need `min` or `max` for that to be useful,
since it's trivial to implement using comparison operators.
Basic numeric types require compiler magic and thus belong in the standard
library. Likewise,
> On 30 Aug 2016, at 10:18, Xiaodi Wu via swift-evolution
> wrote:
>
> As an additive proposal, I don't think this would be in scope for the current
> phase of Swift 4.
>
> Looking forward, though, I'm not sure this belongs in the standard library.
> In general, my understanding is that Swif
As an additive proposal, I don't think this would be in scope for the
current phase of Swift 4.
Looking forward, though, I'm not sure this belongs in the standard library.
In general, my understanding is that Swift's standard library is
deliberately small, and that the criteria for additions are t
Tim,
The protocol extension alone would be sufficient, but for as long as the
global functions
`min` and `max` are still around I thought adding a global clamp function
would make
for good symmetry.
I'll write a small draft proposal to illustrate my idea a little better.
What does the community
What would the point of a free function be if you already have a protocol
extension?
> Georgios, Yes lets go with clamp for a name!
>
> Pyry, Originally I thought of just adding a global function akin to `min`
> and `max` but I am also
> in favour of adding the above extension to `Comparable`.
>
Georgios, Yes lets go with clamp for a name!
Pyry, Originally I thought of just adding a global function akin to `min`
and `max` but I am also
in favour of adding the above extension to `Comparable`.
I think having both the global function and the protocol extension for
`clamp` would be great.
-
> On 25 Aug 2016, at 12:05, Nicholas Maccharoli wrote:
>
> I personally see merit in adding a function to bound the value of a variable
> within a range and think it would be simple to write with the existing
> implementations of `min` and `max` with something like:
>
> public func bounds(v
> In the standard library there is a `min` and a `max` function but there isn't
> a `bounds` function, or a function that takes a value and an upper and lower
> bound and returns that value if it is
Perhaps ‘clamp’ would be a better name?
___
swift-evo
Swift Evolution Community,
In the standard library there is a `min` and a `max` function but there
isn't
a `bounds` function, or a function that takes a value and an upper and
lower bound and returns that value if it is within the specified range or
if not the closer of the lower or upper values s
13 matches
Mail list logo