I’m writing some code that deals with ranges of “sequence numbers”, which are
consecutively-assigned positive 64-bit integers, thus Range in Swift.
I’m having trouble handling half-open ranges with no maximum, which are very
commonly used for representing all items created since a certain time.
> On Apr 16, 2016, at 12:53 PM, Dmitri Gribenko wrote:
>
> It needs to be a signed integer. And a signed integer needs a distance type
> itself.
Yeah, there’s an infinite regress implied there, since a distance type has to
be one bit larger than its source type.
The
On Sat, Apr 16, 2016 at 8:29 AM, wrote:
> Is there any reason that Distance has to be a simple Int? Since it’s defined
> per-type, UInt64 could use a custom struct without impacting the performance
> of other types:
It needs to be a signed integer. And a signed integer
Is there any reason that Distance has to be a simple Int? Since it’s defined
per-type, UInt64 could use a custom struct without impacting the performance of
other types:
struct UInt64Distance : Comparable { //I'm not sure what else it needs to
conform to
var distance: UInt64
var
On Fri, Apr 15, 2016 at 4:41 PM, Jens Alfke wrote:
>
>
> --Jens [via iPhone]
>
>> On Apr 15, 2016, at 4:26 PM, Dmitri Gribenko wrote:
>>
>> The distance is signed so that we can represent negative distances.
>> r.distance(from:to:) should be able to
--Jens [via iPhone]
> On Apr 15, 2016, at 4:26 PM, Dmitri Gribenko wrote:
>
> The distance is signed so that we can represent negative distances.
> r.distance(from:to:) should be able to measure distances backwards.
Yeah, makes sense in general, just not for this