Re: [swift-users] Reason for Swift not having readwrite reflection

2015-12-17 Thread Joe Groff via swift-users
> On Dec 17, 2015, at 10:54 AM, Gergely Orosz via swift-users > wrote: > > As a user of swift, building projects on top of it, the single biggest > limitation I've come across is that all my unit tests are significantly more > bloated compared to Objective C... because

Re: [swift-users] Very unexpected automatic behaviour between StringLiteralConvertible and pattern matching!

2016-01-06 Thread Joe Groff via swift-users
> On Jan 6, 2016, at 2:31 PM, David Hart wrote: > > I can file those bugs. Would it be beneficial if I also created failing unit > tests? > David. Definitely. Thanks for uncovering these issues. -Joe ___ swift-users mailing list

Re: [swift-users] Cross Compiling Swift for Bare Metal?

2015-12-21 Thread Joe Groff via swift-users
> On Dec 19, 2015, at 6:53 PM, Chaitanya Mannem via swift-users > wrote: > > Hi, > > > I wanted to know if it is possible to compile swift code for bare metal. I > know there is a runtime but does swift depend on it to execute even if I > don't use those features?,

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Joe Groff via swift-users
> On Dec 18, 2015, at 3:13 PM, David Turnbull via swift-users > wrote: > > On Fri, Dec 18, 2015 at 2:31 PM, Janosch Hildebrand via swift-users > > wrote: > You will also want to have this code in the same module that

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Joe Groff via swift-users
Do you have the optimizer enabled (using -O)? I see inlining happening as you'd expect. This: let x = Vector2(x: 1, y: 1) foo(x.x) foo(x.r) optimizes down to: %15 = integer_literal $Builtin.Int64, 1 // user: %16 %16 = struct $Int (%15 : $Builtin.Int64)// users: %17, %17,

Re: [swift-users] C vararg: Swift Package Manager and System Modules

2015-12-18 Thread Joe Groff via swift-users
> On Dec 18, 2015, at 1:52 AM, Daniel Eggert via swift-users > wrote: > >> On 17 Dec 2015, at 22:47, Daniel Eggert via swift-users >> wrote: >> >> If I need access to the C fcntl(2): >> >> int fcntl(int, int, ...) >> >> can I get the

Re: [swift-users] Recursive Enums and String Literals

2015-12-28 Thread Joe Groff via swift-users
> On Dec 27, 2015, at 2:14 AM, Rick Gigger via swift-users > wrote: > > I am trying to create an enum that will allow me to create literals that > combine Int, Double and String types, as well as any Array of any combination > of those, and any Dictionary mapping a

Re: [swift-users] Setting up properties

2015-12-21 Thread Joe Groff via swift-users
> On Dec 21, 2015, at 5:14 PM, Erica Sadun via swift-users > wrote: > > For a friend: > > This won't work. > > class DerpController { > private(set) var derp: Bool = { > return _findDerp() != nil > }() > > private func _findDerp() ->

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

2016-06-13 Thread Joe Groff via swift-users
> On Jun 11, 2016, at 10:29 AM, Karl Pickett via swift-users > wrote: > > 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 >

Re: [swift-users] Generic type metadata pattern not found?

2016-06-13 Thread Joe Groff via swift-users
> On Jun 11, 2016, at 5:24 PM, Jon Shier via swift-users > wrote: > > Swift Users: > In preparation for an upcoming iOS app project I’m trying out some new > project layout strategies. One of which is putting my network layer and > custom UI elements in

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

2016-06-13 Thread Joe Groff via swift-users
> On Jun 13, 2016, at 1:39 PM, Jens Alfke <j...@mooseyard.com> wrote: > > >> On Jun 13, 2016, at 9:45 AM, Joe Groff via swift-users >> <swift-users@swift.org> wrote: >> >> It's not undefined behavior in that we try to ensure that memory safety

Re: [swift-users] expression too complex

2016-06-06 Thread Joe Groff via swift-users
> On Jun 6, 2016, at 3:06 PM, G B via swift-users wrote: > > Is progress being made on the type checker to get the compiler to stop > whinging about the complexity of expressions? Yes, a lot of cases work much better in Swift 3. You might give these a try in a nightly

Re: [swift-users] Can't get Error pattern matching to work cross framework and command line tool

2016-05-31 Thread Joe Groff via swift-users
> On May 31, 2016, at 8:50 AM, Joakim Hassila via swift-users > wrote: > > Hi Ian, > > Nope, it is the only definition - I also actually have tried to fully qualify > it as Z.Transaction.Error.NotFound without any difference both at the throw > and catch sides. > > I

Re: [swift-users] Swift closure memory problem

2016-05-27 Thread Joe Groff via swift-users
> On May 27, 2016, at 3:57 AM, Alon Muroch via swift-users > wrote: > > Hi everyone ! > Its my first time writing here so i hope i could contribute. > > The following code seems to create a retain cycle that doesn't let SomeClass1 > to release. Am i missing something

Re: [swift-users] Swift closure memory problem

2016-05-27 Thread Joe Groff via swift-users
> On May 27, 2016, at 11:42 AM, Alon Muroch wrote: > > for example { () -> Void > } Can you please paste a complete example of code that triggers a leak, as text? -Joe > On Fri, May 27, 2016 at 7:59 PM, Joe Groff wrote: > > > On May 27, 2016, at 3:57

Re: [swift-users] Can't get Error pattern matching to work cross framework and command line tool

2016-06-01 Thread Joe Groff via swift-users
Thank you! -Joe > On May 31, 2016, at 9:49 PM, Joakim Hassila wrote: > > Hi Joe, > > Absolutely, I just filed rdar://26569913 (used Radar according to community > guidelines of putting projects requiring Xcode to reproduce there). > > I hope I captured the dependencies /

Re: [swift-users] expression too complex

2016-06-16 Thread Joe Groff via swift-users
> On Jun 16, 2016, at 1:59 PM, davel...@mac.com wrote: > > > Joe, > > I had an expression that worked fine with Swift2.2 but Swift3 (Xcode 8 > version) complains it's too complex: > > The variables are of type CGPoint and the function returns a Bool. > >return (pt.x - p0.x) * (p1.y -

Re: [swift-users] CGContext endPage method ambiguous (two candidates) Swift 3/Xcode 8

2016-06-17 Thread Joe Groff via swift-users
> On Jun 16, 2016, at 1:49 PM, Dave Reed via swift-users > wrote: > > I've got a project I had been working on using Swift2.2 and decided to > migrate to Swift3 (using Xcode 8 beta) before the project gets any bigger. I > successfully migrated everything except I have

Re: [swift-users] Hexadecimal floating-point literals

2016-06-27 Thread Joe Groff via swift-users
> On Jun 26, 2016, at 12:50 AM, Toni Suter via swift-users > wrote: > > Hi, > > I have a question regarding hexadecimal floating-point literals. According to > the Lexical Structure >

Re: [swift-users] Reordering tuples with named components

2016-04-05 Thread Joe Groff via swift-users
> On Apr 5, 2016, at 12:40 PM, tuuranton--- via swift-users > wrote: > > This code works great in Swift 2.2: > > > func foo() -> (a: String, b: Int) { > return ("asdf", 4) > } > > var z: (b: Int, a: String) > z = foo() > > print("\(z.0)") //4 >

Re: [swift-users] Compiling C-usable objects/shared objects

2016-04-11 Thread Joe Groff via swift-users
> On Apr 11, 2016, at 11:36 AM, Daniel Farina via swift-users > wrote: > > I've been playing with recent versions of Swift on Linux and think the whole > thing is rather neat. I'm most curious about how swift programs might be > embeddable in C projects. > > I found a

Re: [swift-users] Compiling C-usable objects/shared objects

2016-04-11 Thread Joe Groff via swift-users
> On Apr 11, 2016, at 11:57 AM, Daniel Farina wrote: > > On Mon, Apr 11, 2016 at 11:47 AM Joe Groff wrote: > > > On Apr 11, 2016, at 11:36 AM, Daniel Farina via swift-users > > wrote: > > > > I've been playing with recent versions of

Re: [swift-users] Serious Issue with Project Preprocessor Build Setting, Xcode 7.3 and Swift.

2016-03-23 Thread Joe Groff via swift-users
> On Mar 23, 2016, at 9:43 AM, James Campbell via swift-users > wrote: > > We are experiencing an issue when compiling swift code under Xcode 7.3. > > Preprocessor macros specified in the Xcode Project aren't imported into > swift. Ones manually declared in code are

Re: [swift-users] Mapping C semantics to Swift

2016-05-19 Thread Joe Groff via swift-users
> On May 19, 2016, at 10:00 AM, Ken Burgett via swift-users > wrote: > > I would like to know if a struct in Swift has any guarantee of contiguity, > like a struct in C. I am attempting to port a C program that makes many > assumptions about the underlying semantics

Re: [swift-users] Unexpected Optional unwrapping in generic fn

2016-05-16 Thread Joe Groff via swift-users
> On May 15, 2016, at 4:13 PM, Michael Gardner via swift-users > wrote: > > I'm having trouble understanding why the following code is trying to unwrap > an Optional. > > > > class Proxy { > var value:T > init(_ value:T) { >

Re: [swift-users] Initializer inheritance doesn't work with generic class?

2016-05-16 Thread Joe Groff via swift-users
This is a known bug. I think Slava's currently working on fixing it. > On May 15, 2016, at 2:41 PM, Neil Faiman via swift-users > wrote: > > Here is another, more blatant example of the failure to inherit initializers > from a generic base class: > >class Concrete {

Re: [swift-users] Conditional generic initializers?

2016-05-16 Thread Joe Groff via swift-users
> On May 15, 2016, at 11:55 AM, Neil Faiman via swift-users > wrote: > > Is this a relatively new language change? When I try it with the version of > Swift that comes with Xcode 7.3.1, I get > >error: same-type requirement makes generic parameters 'T1' and 'T2' >

Re: [swift-users] Range subscript is ambiguous

2016-05-16 Thread Joe Groff via swift-users
> On May 15, 2016, at 5:31 AM, Neil Faiman via swift-users > wrote: > > This function seems simple enough: > > >func foo(a: [Int], n: Int) { >var x : [Int] = a[0..} > > But it doesn’t compile. > >error: ambiguous subscript with base type

Re: [swift-users] Default value for throwing closure argument of a rethrowing function

2016-05-16 Thread Joe Groff via swift-users
> On May 16, 2016, at 2:35 AM, bhargav gurlanka via swift-users > wrote: > > Hi all, > > Could someone please tell me why the following fails? > > func foo(f: () throws -> () = {}) rethrows { > try f() > } > > // Fine > foo({ }) > > // This fails with error: > //

Re: [swift-users] swift redistributable without Xcode

2016-05-06 Thread Joe Groff via swift-users
> On May 6, 2016, at 1:14 PM, Tim Prepscius via swift-users > wrote: > > Greetings, > > Is it possible to build swift using Xcode, and then distribute swift > without Xcode? > Or, does there already is exist some link to swift on OS X which is > not contained in Xcode?

Re: [swift-users] Strange Behavior With Closures

2016-05-05 Thread Joe Groff via swift-users
> On May 4, 2016, at 6:19 PM, bwm003--- via swift-users > wrote: > > Hi Everyone, > I was playing around in Xcode 7.3 with this code... > > /** > > * Represents a future value of type U, from a computation that has not been > done yet. > */ > public struct

Re: [swift-users] Latest development code fails to build

2016-04-13 Thread Joe Groff via swift-users
> On Apr 13, 2016, at 10:27 AM, Charles Lane via swift-users > wrote: > > Every time I try to build any app in Xcode 7.3 with the latest development > snapshot (Apr 12), the build fails with this error: `Command failed due to > signal: Illegal instruction: 4` > Anyone

Re: [swift-users] String initializers and developer ergonomics

2016-05-09 Thread Joe Groff via swift-users
> On May 7, 2016, at 10:39 AM, Austin Zheng via swift-users > wrote: > > Hello Swift users, > > I wanted to run something past you folks and get some opinions/feedback. > > About a month ago on Hacker News I saw someone commenting about how Swift's > string-handling

Re: [swift-users] Why can't structs inherit from other structs?

2016-08-02 Thread Joe Groff via swift-users
> On Aug 1, 2016, at 5:28 PM, Rick Mann via swift-users > wrote: > > It sure seems natural. > > Is there some reason the language can't allow a sub-struct to add member > variables, such that the whole is treated like a contiguous set of members? Class-style

Re: [swift-users] Defer with local variable's state

2016-08-11 Thread Joe Groff via swift-users
> On Aug 11, 2016, at 7:16 AM, Sebastian Hagedorn via swift-users > wrote: > > We often write code that returns early, but has to make sure a bit of code > (e.g., a completion handler) is always called whenever we return, which seems > like a great use case for defer.

Re: [swift-users] Checking whether an object is uniquely referenced, using a weak reference to it

2016-06-28 Thread Joe Groff via swift-users
> On Jun 28, 2016, at 9:32 AM, Jordan Rose via swift-users > wrote: > > >> On Jun 27, 2016, at 18:52, Tim Vermeulen wrote: >> >> Thanks for your reply. It didn’t clear up everything, though. The official >> documentation says "Weak references do

Re: [swift-users] Cannot invoke 'stride' with an argument list of type '(from: Int, to: Int, by: Int)'

2016-07-05 Thread Joe Groff via swift-users
This is a known bug. The definition of 'stride' inside 'Int' for migration from Swift 2 causes the compiler to fail to find the global function. https://bugs.swift.org/browse/SR-1798 -Joe > On Jul 4, 2016, at 8:41 PM, Adriano Ferreira via swift-users > wrote: > > Hi

Re: [swift-users] Chaining struct-mutating funcs

2016-08-05 Thread Joe Groff via swift-users
Since your backing buffer is copy-on-write, you can do the in-place mutation optimization in your immutable implementations, something like this: class C { var value: Int init(value: Int) { self.value = value } } struct S { var c: C } func addInts(x: S, y: S) -> S { var tmp = x //

Re: [swift-users] Draft guide for id-as-Any migration and known issues

2016-08-01 Thread Joe Groff via swift-users
I've also posted the document as a gist, to gather updates as I collect them: https://gist.github.com/jckarter/5ffa9ba75050b94cd2cf9092b332a866 -Joe > On Aug 1, 2016, at 11:46 AM, Joe Groff via swift-users > <swift-users@swift.org> wrote: > > Hi everyone. SE-0116

Re: [swift-users] Set size of byte array

2016-08-09 Thread Joe Groff via swift-users
> On Aug 5, 2016, at 9:42 AM, KS Sreeram via swift-users > wrote: > > >> On 05-Aug-2016, at 1:19 PM, Daniel Vollmer wrote: >> >> I’m by no means a Swift expert (not even a user at the moment), but I don't >> see a way to do this either. The best that

Re: [swift-users] Non-objc protocol inheritance from objc protocol

2017-02-06 Thread Joe Groff via swift-users
> On Feb 6, 2017, at 3:22 PM, Jordan Rose via swift-users > wrote: > > Hi, Pavel. This is definitely supported, and it is indeed a bug that these > are not both producing 'true'. We're tracking this as rdar://problem/24453316 > . I also filed this as

Re: [swift-users] Avoiding an extra copy withUnsafeBytes

2017-01-26 Thread Joe Groff via swift-users
> On Jan 26, 2017, at 7:03 AM, Ray Fix via swift-users > wrote: > > To compute a hash, I want to loop through bytes of a trivial type. To get > the bytes, I use withUnsafeBytes hands me a rawBufferPointer collection type. > Great! > > However this call also requires

Re: [swift-users] Casting function pointers

2017-01-25 Thread Joe Groff via swift-users
> On Jan 25, 2017, at 1:23 AM, Rien via swift-users > wrote: > > I have a case where a callback has the following signature: > > @convention(c) (_ ssl: OpaquePointer?, _ num: UnsafeMutablePointer?, _ > arg: UnsafeMutableRawPointer?) -> Int32 > > But to install this

Re: [swift-users] question about covariant subtyping

2017-02-23 Thread Joe Groff via swift-users
> On Feb 23, 2017, at 4:45 AM, Michael Roitzsch > wrote: > > So I understand that the first issue is a bug and the second may be a bug or > may be intentional. Would you advise that I file them both as bugs then? They're both bugs, ultimately. Slava was just

Re: [swift-users] question about covariant subtyping

2017-02-22 Thread Joe Groff via swift-users
> On Feb 22, 2017, at 8:50 AM, Michael Roitzsch via swift-users > wrote: > > Hi all, > > I am fairly new to Swift, so this may very well be a simple misunderstanding > on my part. > > I was exploring the subtyping rules of Swift, especially regarding > covariance. I

Re: [swift-users] Bool type and reading and writing operation atomicity

2017-01-17 Thread Joe Groff via swift-users
> On Jan 16, 2017, at 3:27 AM, Dale Myers via swift-users > wrote: > > Put simply, are reading and writing to Bools both atomic operations in Swift > (3)? > > Obviously, something reading and then assigning assuming the value doesn't > change between is not correct,

Re: [swift-users] Argument type 'Int' does not conform to expected type 'AnyObject'

2016-09-09 Thread Joe Groff via swift-users
> On Sep 9, 2016, at 2:02 PM, Kevin Nattinger via swift-users > wrote: > > You’ll need to explicitly add the “as NSNumber” now. > > https://github.com/apple/swift-evolution/blob/master/proposals/0072-eliminate-implicit-bridging-conversions.md Or even better, you should

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Joe Groff via swift-users
> On Sep 23, 2016, at 2:20 PM, Jens Persson wrote: > > What is the difference between: > ptr.storeBytes(of: x, toByteOffset: offset, as: type(of: x)) > ptr.advanced(by: offset).assumingMemoryBound(to: type(of: x)).pointee = x > ? > I noticed that the former traps if storing

Re: [swift-users] C interop: passing null pointers to unwrapped unsafe pointers

2016-10-07 Thread Joe Groff via swift-users
> On Oct 7, 2016, at 7:02 AM, Ingo Maier via swift-users > wrote: > > Is there a way in Swift 3 to pass a null pointer to a C function that > takes an implicitly unwrapped unsafe pointer? I understand that > pointer parameters in C that don't specify nullability are

Re: [swift-users] Different behaviour when casting Float and Double to NSNumber

2016-10-05 Thread Joe Groff via swift-users
> On Oct 5, 2016, at 2:30 AM, Lars-Jørgen Kristiansen via swift-users > wrote: > > I'm working with a third party API for some external hardware. One of the > functions takes a NSNumber, and it fails to interact correctly with the > hardware if I cast a Float too

Re: [swift-users] Type inference when assigning the result of reduce to a dictionary

2016-10-04 Thread Joe Groff via swift-users
> On Oct 4, 2016, at 1:58 PM, Martin R wrote: > > >> On 4 Oct 2016, at 21:42, Joe Groff wrote: >> >> >>> On Oct 4, 2016, at 5:20 AM, Martin R via swift-users >>> wrote: >>> >>> I noticed the following when assigning the

Re: [swift-users] NSData vs Data write to string differently?

2016-09-22 Thread Joe Groff via swift-users
> On Sep 22, 2016, at 4:04 PM, Shawn Erickson via swift-users > wrote: > > In general you shouldn't depend on what description returns for classes, etc. > outside of your control unless it is documented (e.g. part of the API > contract). If you want a specific output

Re: [swift-users] Swift 3 likes to tease me

2016-09-23 Thread Joe Groff via swift-users
> On Sep 22, 2016, at 9:51 PM, Gerriet M. Denkmann via swift-users > wrote: > > This line (Swift 3): > if a.responds(to: Selector(“viewControllers") ) > creates this warning: Use '#selector' instead of explicitly constructing a > 'Selector' > > Ok. Following this

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Joe Groff via swift-users
> On Sep 23, 2016, at 1:55 AM, Gerriet M. Denkmann via swift-users > wrote: > > >> On 23 Sep 2016, at 15:47, Gerriet M. Denkmann via swift-users >> wrote: >> >> This used to work in Swift 2.2: >> >> var bitfield: UnsafeMutablePointer? >>

Re: [swift-users] Can anyone please explain this behavior?

2016-09-21 Thread Joe Groff via swift-users
> On Sep 21, 2016, at 2:22 PM, Jens Persson via swift-users > wrote: > > // This little Swift program compiles (and runs) fine: > > func foo() -> Int { return a } > let a = 1 > let b = 2 > print(foo()) > > But if `foo()` returns `b` instead of `a`, I get this compile

[swift-users] Fwd: How to bridge between CoreFoundation and SwiftFoundation on Linux?

2016-09-21 Thread Joe Groff via swift-users
> On Sep 21, 2016, at 1:03 PM, Bouke Haarsma via swift-users > wrote: > > The one that comes with SwiftFoundation > (https://github.com/apple/swift-corelibs-foundation/tree/master/CoreFoundation). > > I think it should be a bug that CFReadStream cannot be bridged to >

Re: [swift-users] Can anyone please explain this behavior?

2016-09-22 Thread Joe Groff via swift-users
> On Sep 22, 2016, at 11:23 AM, Jens Persson wrote: > > Oh, but how can the following (earlier mentioned) example have anything to do > with Script-mode top-level locals being treated as globals? > > Create "AnotherFile.swift" containing: > func f() -> Int { return a } >

Re: [swift-users] Can anyone please explain this behavior?

2016-09-22 Thread Joe Groff via swift-users
> On Sep 22, 2016, at 11:28 AM, Jens Persson wrote: > > Yes, but should the compiler silently accept that? And is this issue really > related to the other issue? No, this is a separate issue. The compiler might be able to catch some obvious cases, but it'd be impossible to

Re: [swift-users] UnsafeMutablePointer on the stack?

2016-10-03 Thread Joe Groff via swift-users
> On Oct 3, 2016, at 10:20 AM, Jens Alfke via swift-users > wrote: > > >> On Oct 2, 2016, at 5:14 PM, Mike Ferenduros via swift-users >> > wrote: >> >> Personally I would be surprised if the malloc caused an actual

Re: [swift-users] Casting tuples to protocols always fails (and the compiler should know)

2016-10-10 Thread Joe Groff via swift-users
> On Oct 10, 2016, at 8:20 AM, Sebastian Hagedorn via swift-users > wrote: > > We encountered a very surprising behaviour in one of our apps, and believe > it’s a bug/missing warning in the Swift compilter, but it would be great if > someone could confirm we’re not

Re: [swift-users] IUO from C Library Interface

2016-10-24 Thread Joe Groff via swift-users
> On Oct 24, 2016, at 3:09 PM, Ryan Lovelett wrote: > >> Not being able to assign the function reference is a bug. As a >> workaround, you should be able to unsafeBitCast CC_SHA1_Update to the >> appropriate type. >> >> -Joe > > Two questions: > > 1. Is this an

Re: [swift-users] IUO from C Library Interface

2016-10-24 Thread Joe Groff via swift-users
> On Oct 24, 2016, at 2:24 PM, Ryan Lovelett via swift-users > wrote: > > import CommonCrypto > > protocol Foo { > associatedtype Context > var context: Context { get set } > var bar: (UnsafeMutablePointer!, UnsafeRawPointer!, CC_LONG) > -> Int32 { get } > } > >

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Joe Groff via swift-users
> On Nov 28, 2016, at 11:42 AM, Nevin Brackett-Rozinsky > <nevin.brackettrozin...@gmail.com> wrote: > > On Mon, Nov 28, 2016 at 2:21 PM, Joe Groff via swift-users > <swift-users@swift.org> wrote: > ExpressibleByFloatLiteral uses a binary float initial value and s

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Joe Groff via swift-users
> On Nov 28, 2016, at 9:22 AM, Alex Blewitt via swift-users > wrote: > > NSDecimal conforms to the ExpressibleBy(Float|Integer)Literal, but that just > means it can be created from a literal value, not the other way around: > >

Re: [swift-users] Indirectly calling functions through assembly

2016-11-28 Thread Joe Groff via swift-users
> On Nov 26, 2016, at 5:20 PM, Krishna Mannem via swift-users > wrote: > > I’ve been messing around with swift and trying to figure out the internals > for fun. I’ve been running into a seg fault while running this gist >

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 2, 2016, at 10:17 AM, Jordan Rose <jordan_r...@apple.com> wrote: > >> >> On Nov 2, 2016, at 09:42, Joe Groff via swift-users <swift-users@swift.org >> <mailto:swift-users@swift.org>> wrote: >> >>> >>> On Nov 1, 2

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users > wrote: > > In my http server i want to manager the memory all the time that we close a > socket, like the example of manager in this link: >

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 2, 2016, at 1:00 PM, Philippe Hausler wrote: > > See: > > https://github.com/apple/swift-corelibs-foundation/blob/d015466450b2675037c6f1ace8e17e73050ccfb9/Foundation/NSURL.swift#L561 > >

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

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 1, 2016, at 6:40 PM, Bernardo Breder via swift-users > wrote: > > Hello, > > I want to create a mini http server project and execute at Ubuntu 15. The > Xcode compile and access the function "autoreleasepool", but when i compile > the same code at Ubuntu,

Re: [swift-users] Data reflection metadata?

2016-10-13 Thread Joe Groff via swift-users
> On Oct 13, 2016, at 9:19 AM, Austin Zheng via swift-users > wrote: > > You probably want to check out this repo: https://github.com/Zewo/Reflection > > It's clever stuff. Really, really reliant on implementation details of the > runtime to function, so I'd be loathe

Re: [swift-users] Overload by return type optionality?

2016-10-13 Thread Joe Groff via swift-users
> On Oct 13, 2016, at 3:27 PM, Rick Mann wrote: > >> >> On Oct 13, 2016, at 14:47 , Joe Groff wrote: >> >> >>> On Oct 13, 2016, at 2:36 PM, Rick Mann via swift-users >>> wrote: >>> >>> It seems I can write this: >>> >>>

Re: [swift-users] Why are Swift Loops slow?

2016-10-12 Thread Joe Groff via swift-users
> On Oct 12, 2016, at 2:25 AM, Gerriet M. Denkmann via swift-users > wrote: > > uint64_t nbrBytes = 4e8; > uint64_t count = 0; > for( uint64_t byteIndex = 0; byteIndex < nbrBytes; byteIndex++ ) > { > count += byteIndex; > if ( ( byteIndex & 0x ) == 0

Re: [swift-users] Swift ported on FreeBSD platform

2016-12-08 Thread Joe Groff via swift-users
> On Dec 7, 2016, at 5:43 PM, Sid via swift-users wrote: > > Swift has been ported to FreeBSD. You can see that here > http://www.freshports.org/lang/swift . > > Can https://swift.org/about/#platform-support be updated to reflect this? > Thank you. It's great that

Re: [swift-users] ObjC vs Swift action selectors

2016-12-06 Thread Joe Groff via swift-users
> On Dec 6, 2016, at 8:54 AM, David Catmull via swift-users > wrote: > > I have a unit test in which I verify that a view controller is correctly > validating items in a context menu. I converted the view controller class to > Swift, keeping the selector names the

Re: [swift-users] ObjC vs Swift action selectors

2016-12-06 Thread Joe Groff via swift-users
> On Dec 6, 2016, at 12:53 PM, David Catmull wrote: > > I tried, writing that as @objc(action:) #selector(ClassName.action(_:)) but > that got an "expected declaration" error. > > I also tried adding @objc(action:) to the method itself (which seems > redundant

Re: [swift-users] Implicitly capture a mutating self

2016-12-16 Thread Joe Groff via swift-users
> On Dec 15, 2016, at 11:46 PM, Richard Wei via swift-users > wrote: > > Hi, > > Swift 3.0.2 seems to have broken my code due to mutating self capture. But I > have to pass inout self to the closure. Any workaround? > > let blockSize = min(512, count) > let

Re: [swift-users] Implicitly capture a mutating self

2016-12-16 Thread Joe Groff via swift-users
> On Dec 16, 2016, at 12:10 PM, Richard Wei wrote: > > `sync` is not escaping. Shadow copy causes the device memory to make a copy, > which can’t be a solution either. I’ll file a radar. > >> Note that, independently, this part looks fishy: >> >>> try! fill<<<(blockSize,

Re: [swift-users] Atomics and Memory Fences in Swift

2016-12-05 Thread Joe Groff via swift-users
> On Dec 4, 2016, at 4:53 PM, Andrew Trick via swift-users > wrote: > > >> On Nov 30, 2016, at 5:40 AM, Anders Ha via swift-users >> > wrote: >> >> Hi guys >> >> I have recently started adopting lock-free atomics

Re: [swift-users] Swift 3 Whole Module Optimization Issue

2016-12-21 Thread Joe Groff via swift-users
> On Dec 21, 2016, at 7:08 PM, Jun Zhang via swift-users > wrote: > > Hi, everyone. >I think I found a swift 3 whole module optimization issue. The code below, > when building with release configuration and running on an iOS 10 real > device, will always causes a

Re: [swift-users] Bls: module (de)-initialization

2016-12-21 Thread Joe Groff via swift-users
> On Dec 21, 2016, at 7:11 PM, Mr Bee wrote: > > > Unloading Swift modules will likely never be supported, since this would > > impose a ton of complexity and performance cost on the runtime for little > > benefit. > > Hmmm… so Swift will only support static linking? I

Re: [swift-users] Memory Leak of Dictionary used in singleton

2017-03-24 Thread Joe Groff via swift-users
> On Mar 11, 2017, at 4:04 PM, Ekaterina Belinskaya via swift-users > wrote: > > Hi everyone! > > I have singleton. It contains a 2 dictionaries. > > struct Stat { > var statHash:String > var displayDescription:String > var displayName:String > var

Re: [swift-users] Swift can’t compile code with OpenGL function pointers

2017-03-30 Thread Joe Groff via swift-users
> On Mar 30, 2017, at 9:40 AM, Kelvin Ma wrote: > > There are hundreds of gl functions… I have to rewrite the signatures for all > of them?? Does GLFW expose any underlying loader mechanism or cached function pointer variables underneath the macros it defines?

Re: [swift-users] Swift can’t compile code with OpenGL function pointers

2017-03-30 Thread Joe Groff via swift-users
> On Mar 30, 2017, at 7:47 AM, Kelvin Ma via swift-users > wrote: > > OpenGL functions are loaded at runtime by a function loader (like GLFW). > They’re defined in a header but obviously they don’t have definitions at > compile time so it causes a slew of linker errors

Re: [swift-users] Set with element of NSObject subclasses didn't work as expected

2017-03-29 Thread Joe Groff via swift-users
> On Mar 28, 2017, at 12:50 PM, Zhao Xin via swift-users > wrote: > > Please see the code first. > > import Foundation > > class Foo:Hashable { > let value:Int > > public var hashValue: Int { return value } > public static func ==(lhs: Foo, rhs: Foo)

Re: [swift-users] Why does casting to Any make my forced downcast not crash?

2017-03-14 Thread Joe Groff via swift-users
> On Mar 13, 2017, at 5:13 AM, Kim Burgestrand via swift-users > wrote: > > Here are two implementations that I'd expect to be equivalent, but > something's different because the first example crashes, whereas the second > example does not crash. > > What's the

Re: [swift-users] Why does casting to Any make my forced downcast not crash?

2017-03-15 Thread Joe Groff via swift-users
> On Mar 15, 2017, at 4:47 AM, Kim Burgestrand wrote: > > On Tue, 14 Mar 2017 at 19:50 Joe Groff > wrote: > > It shouldn't. Please file a bug, if you haven't already. > > Will do! I'll file a bug that casting to `Any` first

Re: [swift-users] Cannot subclass a class with objc_subclassing_restricted attribute

2017-04-17 Thread Joe Groff via swift-users
> On Apr 14, 2017, at 7:41 PM, Rick Mann via swift-users > wrote: > > I'm refactoring some Objective-C code to inherit from a new Swift super > class. This has been going okay, and I've been cleaning up build errors as I > spot them (some auxiliary enums caused enum

Re: [swift-users] Importing empty C structs

2017-04-18 Thread Joe Groff via swift-users
> On Apr 17, 2017, at 6:19 PM, Rick Mann via swift-users > wrote: > > I'm trying to make a module out of a C library and header file. It has at > least one empty struct: > > struct lgs_context_t {}; > > and a function: > > LGS_EXPORT struct lgs_context_t*

Re: [swift-users] Cannot subclass a class with objc_subclassing_restricted attribute

2017-04-18 Thread Joe Groff via swift-users
> On Apr 17, 2017, at 10:11 PM, Rick Mann wrote: > >> >> On Apr 17, 2017, at 08:54 , Joe Groff wrote: >> >> >>> On Apr 14, 2017, at 7:41 PM, Rick Mann via swift-users >>> wrote: >>> >>> I'm refactoring some Objective-C code

Re: [swift-users] Swift/Obj C interoperability: 'Obj C only' functions

2017-03-07 Thread Joe Groff via swift-users
> On Mar 6, 2017, at 2:20 AM, Andrew Hill2 via swift-users > wrote: > > Hi, > > I’ve been looking at making some changes to the ResearchKit library. This is > mainly written in Objective C, with small portions of Swift. > > The Pull request I’ve generated leveraged

Re: [swift-users] Law of Exclusivity runtime false positive?

2017-07-28 Thread Joe Groff via swift-users
> On Jul 28, 2017, at 12:06 AM, David Hart via swift-users > wrote: > > Hello, > > Indeed, I had reduced the code too much. John McCall was kind enough to have > a look and here’s the offending code: > > func layoutHorizontally(leftRect: inout CGRect, rightRect: inout

Re: [swift-users] What is up with names not being Strings any more in Swift 4?

2017-07-17 Thread Joe Groff via swift-users
> On Jul 17, 2017, at 8:26 AM, Jon Shier via swift-users > wrote: > > Like Notification.Name, I believe those types are supposed to help you > namespace your string constants when you access them. I’d recommend using a > code gen tool to generate them from your

Re: [swift-users] What is up with names not being Strings any more in Swift 4?

2017-07-17 Thread Joe Groff via swift-users
> On Jul 17, 2017, at 9:04 AM, Manfred Schubert wrote: > > >> Am 17.07.2017 um 17:47 schrieb Joe Groff : >> >> Yeah, this is the intended use pattern for these namespaced constant. You >> don't need the `rawValue:` label, though: >> >> extension

Re: [swift-users] Swift alternative for heterogeneous collection of objects with "generic" contents.

2017-06-30 Thread Joe Groff via swift-users
> On Jun 29, 2017, at 10:59 PM, Mikhail Seriukov via swift-users > wrote: > > Hello everyone, > In objc there is quite common pattern when we use a base class with a type > property and concrete subclasses where type is uniquely identifying the > subclass. > We can

Re: [swift-users] Is '_ = x' guaranteed to hold a reference to x?

2017-06-30 Thread Joe Groff via swift-users
> On Jun 30, 2017, at 12:25 PM, Mike Ferenduros > wrote: > > Ah, I think I was unclear - I want to extend the lifetime into an escaping > closure, not just within a scope, and I was wondering what the minimal way is > to do that. I see. Using

Re: [swift-users] Is '_ = x' guaranteed to hold a reference to x?

2017-06-30 Thread Joe Groff via swift-users
> On Jun 30, 2017, at 12:13 PM, Mike Ferenduros > wrote: > > With an empty body, you mean? I'd say it's probably more readable to nest the code that's dependent on the lifetime of the object in the block body, though you can just put `withExtendedLifetime(x) { }`

Re: [swift-users] intercept fatalError() or other termination messages from swift?

2017-06-28 Thread Joe Groff via swift-users
> On Jun 26, 2017, at 7:45 PM, David Baraff wrote: > > Ok, the data is for sure not there, or possibly i’m looking at the wrong > thing. Here is what I see: > > Incident Identifier: 15D12BCE-975B-47B6-BD03-DD8512D40DAF > CrashReporter Key:

Re: [swift-users] Help! Slicing an array is very expensive

2017-05-10 Thread Joe Groff via swift-users
> On May 8, 2017, at 4:47 PM, Rick Mann via swift-users > wrote: > > I have this C library that interacts with some hardware over the network that > produces a ton of data. It tells me up front the maximum size the data might > be so I can allocate a buffer for it,

Re: [swift-users] Unimplemented types in Swift 4 KeyPaths

2017-06-21 Thread Joe Groff via swift-users
> On Jun 19, 2017, at 5:23 PM, Brett Walker via swift-users > wrote: > > Hi all, > > In the Swift 4 Keypaths proposal [0161] there seem to be several types that > are unimplemented (or not working as I expect them to), and I'm not sure > whether these are simply

  1   2   >