[swift-users] Using String

2018-01-10 Thread Michael Ilseman via swift-users
Hello, I just sent an email to swift-dev titled "State of String: ABI, Performance, Ergonomics, and You!” at https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20180108/006407.html, whose gist can be found at https://gist.github.com/milseman/bb39ef7f170641ae52c13600a512782f

Re: [swift-users] Start another program from Swift script

2018-01-04 Thread Michael Ilseman via swift-users
The “Shell Out” package’s source code shows some simple usage of Foundation’s Process: https://github.com/JohnSundell/ShellOut/blob/master/Sources/ShellOut.swift#L33. That package also handles stdout / stdin, but for more sophisticated uses of FileManager the “Files” package’s source has some

Re: [swift-users] UnsafeMutableRawPointer to UnsafeMutablePointer: EXC_BAD_ACCESS on pointee

2017-09-23 Thread Michael Ilseman via swift-users
> On Sep 23, 2017, at 3:44 AM, nyg nyg via swift-users > wrote: > > Hello all, > > I'm trying to get an UnsafeMutablePointer from an > UnsafeMutableRawPointer obtained using the Unmanaged structure: > > class C { var foo = 42, bar = "bar" } > let c = C() > > let rawPointer = Unmanaged.passUn

Re: [swift-users] Should I be using more catchless do blocks?

2017-06-19 Thread Michael Ilseman via swift-users
> On Jun 19, 2017, at 11:47 AM, Michael Savich wrote: > > Yeah, it's all about balance to be sure. Though one benefit of do blocks is > in functions that are tied to a sense of time. It seems to me that the in > case of something like viewDidLoad separating code into too many functions > can

Re: [swift-users] Should I be using more catchless do blocks?

2017-06-19 Thread Michael Ilseman via swift-users
Introducing scope to manage lifetimes of local variables is a useful and valuable practice. Note that it might also be an opportunity to refactor the code. Any do block you want to introduce could also be a local function definition that you call later. Alternatively, it could be generalized and

Re: [swift-users] Importing C system libraries

2017-03-28 Thread Michael Ilseman via swift-users
This is into uncharted territory for me, but it seems you’re building with SwiftPM. You’ll probably want to configure extra compiler flags if that’s possible. You could also bite the bullet and build your C libraries with SwiftPM as well. Hopefully someone on swift-build-dev can help you out. C

Re: [swift-users] Asynchronous error recovering with RecoverableError

2017-03-28 Thread Michael Ilseman via swift-users
New start task: https://bugs.swift.org/browse/SR-4405 Add @escaping to RecoverableError.attemptRecovery > On Mar 28, 2017, at 3:31 PM, Douglas Gregor wrote: > > >> On Mar 28, 2017, at 11:21 AM, Michael Ilseman > > wrote: >>

Re: [swift-users] Asynchronous error recovering with RecoverableError

2017-03-28 Thread Michael Ilseman via swift-users
CC Doug Gregor, who git blame tells me wrote this part. Doug, this slightly predates noescape-by-default. Is this a bug or as intended? > On Mar 28, 2017, at 8:49 AM, Elia Cereda via swift-users > wrote: > > Hi Dennis, > > Thanks for your answer. I can see that my message needs some more con

Re: [swift-users] Importing C system libraries

2017-03-28 Thread Michael Ilseman via swift-users
Sure! In this example, I have built libgit2. I have a directory called Git, and inside that I have the following module map: module Git [system] { header "/libgit2/include/git2.h" export * } When I run, I use: swift -I -L -lgit2 foo.swift inside foo.swift I can: import Git //

Re: [swift-users] Importing C system libraries

2017-03-27 Thread Michael Ilseman via swift-users
behind as an Xcode user... > > Jan > >> On 27 Mar 2017, at 22:59, Michael Ilseman via swift-users >> wrote: >> >> Sure. At a low level, you can create a module.map file and use -L/-l flags >> in your invocation of Swift. If you want to do so at a higher lev

Re: [swift-users] Importing C system libraries

2017-03-27 Thread Michael Ilseman via swift-users
Sure. At a low level, you can create a module.map file and use -L/-l flags in your invocation of Swift. If you want to do so at a higher level, then perhaps SwiftPM can. CCing swift-build-dev for the SwiftPM part. > On Mar 26, 2017, at 3:20 PM, Kelvin Ma via swift-users > wrote: > > Idk if t

Re: [swift-users] Airbnb's Swift 3 Migration Blog

2017-02-07 Thread Michael Ilseman via swift-users
> On Feb 7, 2017, at 4:58 PM, Chengyin Liu wrote: > > Thanks for the feedback! > > > This is probably source-compatibility that you want, not necessarily ABI > > compatibility. > > You are right. Thank you for the correction. > > > BTW, are you mixed-source? If so, were you able to try out

Re: [swift-users] Airbnb's Swift 3 Migration Blog

2017-02-07 Thread Michael Ilseman via swift-users
Comments: > Since the Swift ABI changed between versions 2 and 3, even correct Swift 3 > code that imports Swift 2 libraries will not compile. This incompatibility > made it difficult to parallelize code conversion. This is probably source-compatibility that you want, not necessarily ABI compa

Re: [swift-users] FUSE module for swift

2017-01-06 Thread Michael Ilseman via swift-users
To pass in the option to Clang, use -Xcc instead of -Xswiftc, like: swift test -Xswiftc -DFUSE_USE_VERSION=25 -Xcc -D_FILE_OFFSET_BITS=64 As far as in the module map file, I don’t know if that’s supported[1]. You might be able to make your own header that defines it before including fuse.h, and

Re: [swift-users] What is "binding" memory?

2016-11-01 Thread Michael Ilseman via swift-users
> On Nov 1, 2016, at 11:55 AM, Manfred Schubert via swift-users > wrote: > > The "UnsafeRawPointer Migration" guide talks about "binding memory to a type“ > as if that was a well known term. I have never heard of it yet though, and > googling it returns no relevant results. I do not understan

Re: [swift-users] Implementing a few statistics functions in Swift

2016-10-10 Thread Michael Ilseman via swift-users
> On Oct 8, 2016, at 11:29 AM, Georgios Moschovitis via swift-users > wrote: > > Hey everyone, > > I would like to implement a few statistics functions in Swift (e.g. variance, > standardDeviation, etc) that are computed over a collection. > > I am aware of this library: > > https://github.

Re: [swift-users] private vs. fileprivate on global declaration in Swift3?

2016-09-29 Thread Michael Ilseman via swift-users
All access control modifiers have a degenerate case (roughly) equivalent to another one, and the typical wisdom for which to choose is to analyze your intent and perhaps future intent. “fileprivate” and “private” are identical at global scope. “internal” and “fileprivate” are identical in single

Re: [swift-users] Updating C-wrapper to Swift 3

2016-09-28 Thread Michael Ilseman via swift-users
> On Sep 28, 2016, at 10:03 AM, John Brownie via swift-users > wrote: > > Thanks for the pointers. Good reading, but I'm still confused. I think that > the first issue is clear to me now, but I don't know what I have to do to > make the closure be seen as satisfying the type of the function p

Re: [swift-users] @escaping may only be applied to parameters of function type

2016-09-14 Thread Michael Ilseman via swift-users
> On Sep 13, 2016, at 8:16 PM, Michael Ilseman via swift-users > wrote: > > >> On Sep 13, 2016, at 8:14 PM, Rick Mann wrote: >> >> But the Apple declaration (accessible via Xcode) of the method it's based on >> looks like this

Re: [swift-users] @escaping may only be applied to parameters of function type

2016-09-14 Thread Michael Ilseman via swift-users
> On Sep 13, 2016, at 8:37 PM, Shawn Erickson wrote: > > I am in the process of updating to Xcode 8 release so I can't confirm at the > moment but I am fairly sure I hit a situation with being asked to implement a > func from a protocol that got autocompleted with @escape nested as shown. It

Re: [swift-users] @escaping may only be applied to parameters of function type

2016-09-13 Thread Michael Ilseman via swift-users
> On Sep 13, 2016, at 8:14 PM, Rick Mann wrote: > > But the Apple declaration (accessible via Xcode) of the method it's based on > looks like this: > > open func enumerator(at url: URL, >includingPropertiesForKeys keys: [URLResourceKey]?, >options mask: FileManager.DirectoryEnumeration

Re: [swift-users] @escaping may only be applied to parameters of function type

2016-09-13 Thread Michael Ilseman via swift-users
TL;DR: The optional is already escaping, due to the fact that “T?" is sugar for Optional, and the noescape-by-default rule only applies to types in immediate parameter position. Current Swift master has much better diagnostics for this case. There is not currently a general solution involving e

Re: [swift-users] Swift 3 (Xcode 8 GM) issue with @escaping

2016-09-08 Thread Michael Ilseman via swift-users
> On Sep 7, 2016, at 6:50 PM, Jacob Bandes-Storch wrote: > > On Wed, Sep 7, 2016 at 5:54 PM, Michael Ilseman via swift-users > mailto:swift-users@swift.org>> wrote: > I implemented a better (i.e. correct) diagnostic message for this at > https://github.com/apple/s

Re: [swift-users] Swift 3 (Xcode 8 GM) issue with @escaping

2016-09-07 Thread Michael Ilseman via swift-users
I implemented a better (i.e. correct) diagnostic message for this at https://github.com/apple/swift/pull/4670. I want to also do a better diagnostic specifically for aggregate parameters to functions (e.g. optional closures), but that requires more work in the type checker. Basically, @escaping

Re: [swift-users] Secure Coding Guideline and SWIFT 3.0 release

2016-08-10 Thread Michael Ilseman via swift-users
> On Aug 9, 2016, at 10:42 PM, Pandey, Sunil Y via swift-users > wrote: > > Hi Team, > Can anybody please help me with my queries mentioned below: > 1. Do we have secure coding guidelines for SWIFT, please let me know > where can I find the same The Swift open source project does not publis

Re: [swift-users] Import C functions as subscript methods

2016-07-11 Thread Michael Ilseman via swift-users
Subscript is not yet implemented. I will hopefully get that in time for Swift 3. Requiring “newValue” isn’t as well for properties, though it’s coincidentally allowed as a perfectly valid argument label for the setter. > On Jul 11, 2016, at 4:59 AM, Martin R via swift-users > wrote: > > Minim

Re: [swift-users] Generate Swift interface from Objective-C file using clang

2016-07-06 Thread Michael Ilseman via swift-users
The best way I know of is the swift-ide-test tool, and you’ll see it being invoked by many of the ClangImporter tests. > On Jul 6, 2016, at 10:45 AM, Ryan Wilson via swift-users > wrote: > > Hi everyone, > > In Xcode, I can generate a Swift interface for an Objective-C file by using > the as

Re: [swift-users] An OpenGL math library in pure Swift

2016-01-05 Thread Michael Ilseman via swift-users
> On Jan 4, 2016, at 7:11 PM, David Turnbull via swift-users > wrote: > > I've been working on a math library for SwiftGL. It's looking good. Vector2, > Vector3, Vector4, Matrix2x2, Matrix3x3, Matrix4x4 are implemented with all > arithmetic. You can even swizzle just like GLSL. > > var myVec