Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-14 Thread Kevin Ballard via swift-evolution
On Fri, Dec 9, 2016, at 11:50 AM, Dave Abrahams via swift-evolution wrote: > > on Fri Dec 09 2016, Andrew Trick wrote: > > >> On Dec 9, 2016, at 10:27 AM, Dave Abrahams via swift-evolution > > wrote: > >> > >> > >> on Thu Dec 08 2016,

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-12 Thread Andrew Trick via swift-evolution
> On Dec 9, 2016, at 11:50 AM, Dave Abrahams via swift-evolution > wrote: > > > on Fri Dec 09 2016, Andrew Trick wrote: > >>> On Dec 9, 2016, at 10:27 AM, Dave Abrahams via swift-evolution >> wrote: >>> >>>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-09 Thread Dave Abrahams via swift-evolution
on Fri Dec 09 2016, Andrew Trick wrote: >> On Dec 9, 2016, at 10:27 AM, Dave Abrahams via swift-evolution > wrote: >> >> >> on Thu Dec 08 2016, Xiaodi Wu > > wrote: >> > >>> On Thu, Dec 8, 2016 at 6:53 PM,

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-09 Thread Dave Abrahams via swift-evolution
on Thu Dec 08 2016, Ben Cohen wrote: > Probably needs an argument label since it's performing an explicit purpose, > not just a vanilla > conversion initializer. So maybe > UnsafeRawBufferPointer.init(rebasing:) I disagree that we need a label here. It's a

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-09 Thread Andrew Trick via swift-evolution
> On Dec 9, 2016, at 10:27 AM, Dave Abrahams via swift-evolution > wrote: > > > on Thu Dec 08 2016, Xiaodi Wu > wrote: > >> On Thu, Dec 8, 2016 at 6:53 PM, Ben Cohen via swift-evolution < >> swift-evolution@swift.org> wrote: >> >>>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-09 Thread Andrew Trick via swift-evolution
> On Dec 9, 2016, at 10:22 AM, Dave Abrahams wrote: > > > on Thu Dec 08 2016, Jordan Rose wrote: > >>> On Dec 8, 2016, at 16:22, Andrew Trick via swift-evolution >>> wrote: >>> In practice, it needs to be able to interoperate with [UInt8] and

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-09 Thread Dave Abrahams via swift-evolution
on Thu Dec 08 2016, Xiaodi Wu wrote: On Thu, Dec 8, 2016 at 6:53 PM, Ben Cohen via swift-evolution < swift-evolution@swift.org> wrote: On Dec 8, 2016, at 4:35 PM, Jordan Rose via swift-evolution < swift-evolution@swift.org> wrote: Um, Sequence doesn’t have a subscript (or indexes).

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-09 Thread Dave Abrahams via swift-evolution
on Thu Dec 08 2016, Ben Cohen wrote: On Dec 8, 2016, at 4:35 PM, Jordan Rose via swift-evolution wrote: Um, Sequence doesn’t have a subscript (or indexes). Sequences are single-pass. So if this is important, it needs to stay a Collection. Just because

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-09 Thread Dave Abrahams via swift-evolution
on Thu Dec 08 2016, Jordan Rose wrote: On Dec 8, 2016, at 16:22, Andrew Trick via swift-evolution wrote: In practice, it needs to be able to interoperate with [UInt8] and be interchangeable in the same generic context. e.g. `byteBuffer +=

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Ben Cohen via swift-evolution
Probably needs an argument label since it's performing an explicit purpose, not just a vanilla conversion initializer. So maybe UnsafeRawBufferPointer.init(rebasing:) Or since we have same-type constrained extensions now on master maybe you could do it as a property: extension

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Ben Cohen via swift-evolution
So now that I look at it, it appears UnsafeRawBufferPointer(copyBytes:) has the same problems we are trying to solve on initialize(as:from) i.e. it is completely at the mercy of the passed-in collection's count being accurate, and if it isn't it'll scribble over memory. We should probably apply

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Andrew Trick via swift-evolution
> On Dec 8, 2016, at 5:44 PM, Xiaodi Wu via swift-evolution > wrote: > > On Thu, Dec 8, 2016 at 6:53 PM, Ben Cohen via swift-evolution > > wrote: > >> On Dec 8, 2016, at 4:35 PM, Jordan Rose via

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Xiaodi Wu via swift-evolution
On Thu, Dec 8, 2016 at 6:53 PM, Ben Cohen via swift-evolution < swift-evolution@swift.org> wrote: > > On Dec 8, 2016, at 4:35 PM, Jordan Rose via swift-evolution < > swift-evolution@swift.org> wrote: > > Um, Sequence doesn’t have a subscript (or indexes). Sequences are > single-pass. So if this

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Xiaodi Wu via swift-evolution
Sorry, let me clarify. Can you, Dave, elaborate as to why the issue you stated as "this" ("untyped memory without bounds checks" conforming to Collection) seems, as you say, "suspect"? On Thu, Dec 8, 2016 at 18:32 Dave Abrahams wrote: on Thu Dec 08 2016, Xiaodi Wu wrote:

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Andrew Trick via swift-evolution
> On Dec 8, 2016, at 4:54 PM, Jordan Rose wrote: > > >> On Dec 8, 2016, at 16:53, Ben Cohen > > wrote: >> >> >>> On Dec 8, 2016, at 4:35 PM, Jordan Rose via swift-evolution >>>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Jordan Rose via swift-evolution
> On Dec 8, 2016, at 16:53, Ben Cohen wrote: > > >> On Dec 8, 2016, at 4:35 PM, Jordan Rose via swift-evolution >> > wrote: >> >> Um, Sequence doesn’t have a subscript (or indexes). Sequences are >>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Ben Cohen via swift-evolution
> On Dec 8, 2016, at 4:35 PM, Jordan Rose via swift-evolution > wrote: > > Um, Sequence doesn’t have a subscript (or indexes). Sequences are > single-pass. So if this is important, it needs to stay a Collection. > Just because something fulfills one of the

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Jordan Rose via swift-evolution
> On Dec 8, 2016, at 16:22, Andrew Trick via swift-evolution > wrote: > > In practice, it needs to be able to interoperate with [UInt8] and be > interchangeable in the same generic context. > > e.g. `byteBuffer += rawBuffer[payloadIndex..

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Dave Abrahams via swift-evolution
on Thu Dec 08 2016, Xiaodi Wu wrote: Can you elaborate on this? Why aren't you sure this is a wise idea? Whom are you asking? What is “this?” -- -Dave ___ swift-evolution mailing list swift-evolution@swift.org

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Andrew Trick via swift-evolution
> On Dec 8, 2016, at 12:50 PM, Dave Abrahams via swift-evolution > wrote: > > > on Thu Dec 08 2016, Ben Cohen wrote: > >>> On Dec 2, 2016, at 8:27 PM, Nate Cook wrote: >>> On Dec 2, 2016, at 2:12 PM, Ben Cohen via swift-evolution

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Xiaodi Wu via swift-evolution
Can you elaborate on this? Why aren't you sure this is a wise idea? On Thu, Dec 8, 2016 at 16:19 Dave Abrahams via swift-evolution < swift-evolution@swift.org> wrote: > > on Thu Dec 08 2016, Alexis Beingessner wrote: > > >> On Dec 8, 2016, at 3:50 PM, Dave Abrahams

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Dave Abrahams via swift-evolution
on Thu Dec 08 2016, Alexis Beingessner wrote: >> On Dec 8, 2016, at 3:50 PM, Dave Abrahams via swift-evolution >> wrote: >> >> >> on Thu Dec 08 2016, Ben Cohen wrote: >> > On Dec 2, 2016, at 8:27 PM, Nate Cook

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Alexis Beingessner via swift-evolution
> On Dec 8, 2016, at 3:50 PM, Dave Abrahams via swift-evolution > wrote: > > > on Thu Dec 08 2016, Ben Cohen wrote: > >>> On Dec 2, 2016, at 8:27 PM, Nate Cook wrote: >>> On Dec 2, 2016, at 2:12 PM, Ben Cohen via swift-evolution

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Dave Abrahams via swift-evolution
on Thu Dec 08 2016, Ben Cohen wrote: >> On Dec 2, 2016, at 8:27 PM, Nate Cook wrote: >> >>> On Dec 2, 2016, at 2:12 PM, Ben Cohen via swift-evolution >>> > >>> wrote: > >>> On Dec 1, 2016, at 11:33 PM, Nate

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-08 Thread Ben Cohen via swift-evolution
> On Dec 2, 2016, at 8:27 PM, Nate Cook wrote: > >> On Dec 2, 2016, at 2:12 PM, Ben Cohen via swift-evolution >> > wrote: >> >>> On Dec 1, 2016, at 11:33 PM, Nate Cook via swift-evolution >>>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-02 Thread Nate Cook via swift-evolution
> On Dec 2, 2016, at 2:12 PM, Ben Cohen via swift-evolution > > wrote: > >> On Dec 1, 2016, at 11:33 PM, Nate Cook via swift-evolution >> > wrote: >> >> 3) Make all buffer

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-02 Thread Hooman Mehr via swift-evolution
How about providing an Int subscript in addition to switching the index type for the purpose of Subsequence? > On Dec 2, 2016, at 2:12 PM, Ben Cohen via swift-evolution > wrote: > > >> On Dec 1, 2016, at 11:33 PM, Nate Cook via swift-evolution >>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-02 Thread Hooman Mehr via swift-evolution
+1 on the third option it being clearly the best way to model pointers. Making the index strideable makes its use in index computations easy. It takes a bit care to make it work as conveniently for UnsafeBufferPointer where the stride will need to be special. > On Dec 1, 2016, at 11:33 PM,

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-01 Thread Nate Cook via swift-evolution
> On Nov 30, 2016, at 6:15 PM, Dave Abrahams via swift-evolution > wrote: > > on Wed Nov 30 2016, Kevin Ballard > wrote: > >> This sounds like a sensible idea. But there is one behavioral change you >>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-01 Thread Dave Abrahams via swift-evolution
on Thu Dec 01 2016, Jordan Rose wrote: >> On Nov 30, 2016, at 16:15, Dave Abrahams via swift-evolution > wrote: >> >> >> on Wed Nov 30 2016, Kevin Ballard >> >> > >> wrote: >>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-12-01 Thread Jordan Rose via swift-evolution
> On Nov 30, 2016, at 16:15, Dave Abrahams via swift-evolution > wrote: > > > on Wed Nov 30 2016, Kevin Ballard > wrote: > >> This sounds like a sensible idea. But there is one behavioral change you >>

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-11-30 Thread Dave Abrahams via swift-evolution
on Wed Nov 30 2016, Kevin Ballard wrote: > This sounds like a sensible idea. But there is one behavioral change you > haven't addressed, which is that this changes how indexes work on the > slice. With all other slice types that come to mind, the slice shares > the

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-11-30 Thread Kevin Ballard via swift-evolution
This sounds like a sensible idea. But there is one behavioral change you haven't addressed, which is that this changes how indexes work on the slice. With all other slice types that come to mind, the slice shares the same indexes as the base, e.g. let ary = Array(0..<10) print(ary[3]) //

Re: [swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-11-30 Thread Karl via swift-evolution
+1. Sensible change. > On 30 Nov 2016, at 18:15, Nate Cook via swift-evolution > wrote: > > Hello all— > > This is a proposal for a fairly minor change in slicing behavior for unsafe > buffers. > > Nate > > > -- > > > This proposal changes Swift's typed

[swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

2016-11-30 Thread Nate Cook via swift-evolution
Hello all— This is a proposal for a fairly minor change in slicing behavior for unsafe buffers. Nate -- This proposal changes Swift's typed UnsafeBufferPointers to be their own slice type, like the UnsafeRawBufferPointer types. This is a minor change in the subscript API of