Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Brent Royal-Gordon via swift-users
> On Nov 4, 2016, at 9:45 AM, Ryan Lovelett wrote: > > Just out of curiosity if I looked at the SIL, would that allow me to see > any of that in action? Or would it be too opaque? Maybe. What might be more directly useful is looking at the source for `Data` in Foundation:

Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Joe Groff via swift-users
> On Nov 4, 2016, at 10:12 AM, Rien via swift-users > wrote: > > >> On 04 Nov 2016, at 17:48, Ryan Lovelett wrote: >> >>> I often end up “printing” the addresses or using GDB to take an inside >>> look. >> >> That is a really simple interrogation technique I wish I had thought of >> that! T

Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Rien via swift-users
> On 04 Nov 2016, at 17:48, Ryan Lovelett wrote: > >> I often end up “printing” the addresses or using GDB to take an inside >> look. > > That is a really simple interrogation technique I wish I had thought of > that! Thank you! > >> One thing that tripped me up: if you use inout variables, th

Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Ryan Lovelett via swift-users
> I often end up “printing” the addresses or using GDB to take an inside > look. That is a really simple interrogation technique I wish I had thought of that! Thank you! > One thing that tripped me up: if you use inout variables, the observers > will be triggered once the function completes. Even

Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Ryan Lovelett via swift-users
> Do you mean, "did I make two copies of the `Data`, one in a top-level > variable named `d` and the other in a parameter named `buffer`"? That is more precisely what I meant. Mutters to self: "Precision of language, Ryan!" That fairly completely answers my quandary. Thank you for your time and e

Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Rien via swift-users
> On 04 Nov 2016, at 13:59, Ryan Lovelett via swift-users > wrote: > > struct Foo { > init(from buffer: Data) { > bar = integer(withBytes: Array(buffer[4..<6])) > baz = integer(withBytes: Array(buffer[6..<8])) > ... > } > > let d = Data(count: Int(3e+8)) > let f = Foo(from: d) >

Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Brent Royal-Gordon via swift-users
> On Nov 4, 2016, at 5:59 AM, Ryan Lovelett via swift-users > wrote: > > struct Foo { > init(from buffer: Data) { > bar = integer(withBytes: Array(buffer[4..<6])) > baz = integer(withBytes: Array(buffer[6..<8])) > ... > } > > let d = Data(count: Int(3e+8)) > let f = Foo(from: d) >

[swift-users] Understanding pass-by-value

2016-11-04 Thread Ryan Lovelett via swift-users
struct Foo { init(from buffer: Data) { bar = integer(withBytes: Array(buffer[4..<6])) baz = integer(withBytes: Array(buffer[6..<8])) ... } let d = Data(count: Int(3e+8)) let f = Foo(from: d) Did I just make two copies of the `Data`? How would I investigate this to understand it