> On Jan 2, 2018, at 11:57 PM, Ben Cohen <[email protected]> wrote:
>
> Hi Daryle,
>
> I think this is a perfect case for an addition to the existing Lazy suite
> (and IMO would make a good evolution proposal too, as this kind of “chunked”
> splitting is a useful feature). You’re right though, there isn’t a good guide
> out there for how to do this (calling any intrepid blogger who wants to write
> one…)
>
> Here’s a sketch of how it would fit into lazy. This is with the latest
> toolchain from master, which makes things a LOT easier now that IndexDistance
> is dead. It’s slightly inefficient because it re-uses Index from Base for its
> index, it would be more efficient to use a start/end pair for the chunks but
> that’s a lot more code :)
I saw that I missed this discussion when I skipped out for 1.5 months. I’m not
sure what the problem with IndexDistance was; abstraction is generally a good
thing. Wouldn’t any awkwardness with “let x: IndexDistance = 0” affect ALL
types besides Int? If you have a problem with that, then the solution would be
to redo Swift’s literal-handling model.
> What’s also interesting is you could (with conditional conformance now that’s
> landed) make it a RandomAccessCollection if the base were random access, but
> not if the base is bidirectional, because you need to be able to calculate
> the size of the last element in constant time.
Is this active, at least in Xcode 9.2? Because I couldn’t get the obvious:
extension ChunkedCollection: RandomAccessCollection where Base:
RandomAccessCollection {
//…
}
to work. (An extension with constraints can’t have an inheritance clause.)
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users