Re: [swift-users] inout params seem to have undefined behavior

2016-06-11 Thread Karl Pickett via swift-users
Wow there are some real doozy inout code examples in there, showing aliasing much more fun than my snippet. Unfortunately I can't understand anything else the doc is talking about. I guess I'll just say a prayer and throw salt over my shoulder if using inout. On Sat, Jun 11, 2016 at 6:05 PM, Bre

[swift-users] inout params seem to have undefined behavior

2016-06-11 Thread Karl Pickett via swift-users
I don't believe the (spartan) docs address this case: func foo(inout a: [Int], inout b: Int) { let acopy = a a = [4, 5, 6] print(acopy) // prints "[1, 2, 3]" b = 99 print(a) // prints "[4, 5, 6]" print(acopy) // prints "[1, 2, 99]" (e.g. a let variable changed!) } var

[swift-users] Automatically dump stack trace on trap

2015-12-22 Thread Karl Pickett via swift-users
Having stack traces on critical faults is an "enterprisey" feature that I like. It would be nice if swift allowed customization of what happened on a trap (like array out of bounds), so it dumped the thread's stack trace to stderr before exiting. I can simulate the desired behavior by installing

Re: [swift-users] Is there a way to @NoInline a func or method?

2015-12-10 Thread Karl Pickett via swift-users
an-inline-function > > - mish > > On Dec 10, 2015, at 8:23 AM, Karl Pickett via swift-users < > swift-users@swift.org> wrote: > > Two use cases: > > 1. poking around in the asm for learning. Currently one can work around > by putting funcs in different files

[swift-users] Confusing doc re: metatype type, also doesn't compile on linux

2015-12-07 Thread Karl Pickett via swift-users
This code example: if someInstance.dynamicType === someInstance.self { print("The dynamic and static type of someInstance are the same") } else { print("The dynamic and static type of someInstance are different") } // prints "The dynamic and static type of someInstance are different” Does

Re: [swift-users] Are structs really always pessimistically copied when calling funcs?

2015-12-07 Thread Karl Pickett via swift-users
programmers worried about speed and stack usage run away screaming, and not give swift a try. On Mon, Dec 7, 2015 at 11:53 AM, Joe Groff wrote: > > On Dec 6, 2015, at 5:16 PM, Karl Pickett via swift-users < > swift-users@swift.org> wrote: > > I have a struct and thi

[swift-users] Are structs really always pessimistically copied when calling funcs?

2015-12-07 Thread Karl Pickett via swift-users
I have a struct and this code: func test() { precondition(sizeof(Foo) == 128) let s = Foo() for _ in 0..<100_000_000 { doSomething(s) } } The asm (on LInux, with -O) is showing me that s is being re-initialized on every iteration of the loop. I was hoping that thanks to