Re: [swift-users] Rethrows issue

2017-12-31 Thread Jacob Bandes-Storch via swift-users
On Sat, Dec 30, 2017 at 11:35 PM, Nevin Brackett-Rozinsky via swift-users < swift-users@swift.org> wrote: > So, I know this doesn’t actually address your issue, but I think it is > important to clarify that “rethrows” does not guarantee anything about the > *type* of error thrown by a function.

Re: [swift-users] still wrestling with a type conversion problem

2017-07-04 Thread Jacob Bandes-Storch via swift-users
On Tue, Jul 4, 2017 at 7:21 AM, David Baraff wrote: > > func decoded(_ input: Any) -> Set { > if let listVal = input as? [Set.Element] { > return Set(listVal) > } > return self > } > > This looks a little weird — what is `self`

Re: [swift-users] still wrestling with a type conversion problem

2017-07-03 Thread Jacob Bandes-Storch via swift-users
Using a protocol with an "as?" cast convinces the compiler to do a dynamic lookup for a protocol conformance based on the value's actual type: protocol MyEncodable { func encoded() -> Any } func encode(_ value: T) -> Any { if let value = value as? MyEncodable {

Re: [swift-users] Anyone else having trouble getting swift to build?

2017-03-05 Thread Jacob Bandes-Storch via swift-users
Shot in the dark: are you using the latest Xcode beta? On Sun, Mar 5, 2017 at 3:03 PM, David Sweeris via swift-users < swift-users@swift.org> wrote: > In particular, the "utils/build-script -x” will fail with 84 errors on my > system. As best as I can tell, they're all/mostly linker errors

Re: [swift-users] Ambiguous reference to members of FileHandle

2017-02-22 Thread Jacob Bandes-Storch via swift-users
I just started a swift-evolution thread related to this: https://lists.swift.org/pipermail/swift-evolution/ Week-of-Mon-20170220/032890.html There's also a relevant bug: https://bugs.swift.org/browse/SR-2654 On Wed, Feb 22, 2017 at 3:10 PM, Jordan Rose via swift-users < swift-users@swift.org>

Re: [swift-users] for with optional collection?

2017-02-10 Thread Jacob Bandes-Storch via swift-users
To me it would seem more logical as "for x in array? { }" — to parallel "for case let x? in array { }" On Fri, Feb 10, 2017 at 1:03 PM, Rick Mann via swift-users < swift-users@swift.org> wrote: > I love the idea of for in? (Or even for? In). You should pitch that to > evolution. > > Sent from

Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-10 Thread Jacob Bandes-Storch via swift-users
Got some clarity on this from Apple folks on Twitter: https://twitter.com/jtbandes/status/830159670559993856 On Fri, Feb 10, 2017 at 12:54 PM, Michel Fortin wrote: > I did file one (30314719). I might not have explained the problem clearly > enough, I suppose, because

Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-10 Thread Jacob Bandes-Storch via swift-users
This seems like a bug (missing feature?) in how the API is imported for Swift. You might consider filing a Radar. On Thu, Feb 9, 2017 at 3:12 PM Michel Fortin via swift-users < swift-users@swift.org> wrote: > The `string` property of `NSTextStorage` is of type `String`, but the > contract it

Re: [swift-users] source for a Swift module's interface

2017-01-16 Thread Jacob Bandes-Storch via swift-users
You can print out the interface using `:type lookup MyModule` in the REPL, as discussed here: https://bugs.swift.org/browse/SR-2502 On Mon, Jan 16, 2017 at 6:18 PM, Dave Yost via swift-users < swift-users@swift.org> wrote: > > In Xcode I can put the caret on Darwin in "import Darwin” and use

Re: [swift-users] disambiguate selector

2017-01-13 Thread Jacob Bandes-Storch via swift-users
I filed a bug for this recently: https://bugs.swift.org/browse/SR-3550 Jacob On Fri, Jan 13, 2017 at 12:16 PM, J.E. Schotsman via swift-users < swift-users@swift.org> wrote: > Hello, > > When I wrote this: > > table.performSelector( onMainThread:#selector(NSTableView.reloadData) ) > > I got a

Re: [swift-users] Compiler should issue a warning when a subclass implementation with default values matches a parent implementation without them

2017-01-04 Thread Jacob Bandes-Storch via swift-users
The same ambiguity occurs even without inheritance: class C { func foo() {} func foo(x: Int = 0) {} } Somewhat related: https://bugs.swift.org/browse/SR-1408 On Wed, Jan 4, 2017 at 7:42 PM, Wagner Truppel via swift-users < swift-users@swift.org> wrote: > I’m afraid I wasn’t clear

Re: [swift-users] [swift-dev] String Processing in Swift

2016-12-29 Thread Jacob Bandes-Storch via swift-users
Moving to swift-users. (swift-dev to BCC; swift-dev is for compiler development.) It's also important to know about the methods available on NSString, which are exposed on the String type when you import Foundation: https://developer.apple.com/reference/foundation/nsstring You might also be

Re: [swift-users] Changing precedence of / operator for my protocol?

2016-11-29 Thread Jacob Bandes-Storch via swift-users
You could also define a ** exponentiation operator, i.e. "kilogram * meter / second**2". On Tue, Nov 29, 2016 at 4:15 PM, Rick Mann via swift-users < swift-users@swift.org> wrote: > > > On Nov 29, 2016, at 15:22 , Howard Lovatt > wrote: > > > > Why not define some other

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-20 Thread Jacob Bandes-Storch via swift-users
For a function such as bar() above, the type you want to cast the IMP to would probably be "@convention(c) (Foo, Selector) -> ()". On Sun, Nov 20, 2016 at 9:05 PM, Jeff Kelley wrote: > Thanks Jacob! I tried using unsafeBitCast, but it fails with the > following: “fatal

Re: [swift-users] swift open source help

2016-11-19 Thread Jacob Bandes-Storch via swift-users
The ticketing system at bugs.swift.org has a label for StarterBugs, which should be relatively easy places for a new contributor to jump in: https://bugs.swift.org/secure/IssueNavigator.jspa?reset=true=labels+%3D+StarterBug On Sat, Nov 19, 2016 at 1:20 AM, Ram Krishnamurthappa via swift-users <

Re: [swift-users] Referencing Swift Functions from the Objective-C Runtime

2016-11-18 Thread Jacob Bandes-Storch via swift-users
I imagine unsafeBitCast would be the way to go here. But are you assuming that all of the instance methods have type "(Foo) throws -> Void" ? Or do you somehow want to dynamically use the type information? Jacob On Fri, Nov 18, 2016 at 10:37 PM, Jeff Kelley via swift-users <

Re: [swift-users] hello, first time poster and accelerate question

2016-11-18 Thread Jacob Bandes-Storch via swift-users
Can't you achieve this with a single vector*matrix multiplication? [1/n, 1/n, ..., 1/n] * A = [mean(col 1); mean(col 2); ...; mean(col n)] Or in more legible form: [image: Inline image 1] Jacob On Fri, Nov 18, 2016 at 5:36 AM, Yuma Decaux via swift-users < swift-users@swift.org> wrote:

[swift-users] Swift TextMate bundle updated

2016-10-22 Thread Jacob Bandes-Storch via swift-users
Dear Swift users, Gradually over the past couple months, Michael Sheets and I have been working on updating swift.tmbundle . The subset of you who use TextMate will be happy to hear that the updates finally went live today!  Changes to the language

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

2016-09-23 Thread Jacob Bandes-Storch via swift-users
Once you've determined this object responds to the selector, how do you intend to use it? It's probably best to define your own protocol that has the requirement, and then you can access it via the protocol. In fact, at that point you might even be able to use "as?" rather than

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

2016-09-23 Thread Jacob Bandes-Storch via swift-users
#selector is not used with a string, but with an actual reference to a method. If, for instance, you have a protocol MyVC which declares `var viewControllers: ...` then you can use something like #selector(MyVC.viewControllers). On Thu, Sep 22, 2016 at 9:51 PM, Gerriet M. Denkmann via swift-users

Re: [swift-users] UnsafeMutablePointer Swift 3 conversion

2016-09-07 Thread Jacob Bandes-Storch via swift-users
> > My migration guide landed on swift.org today! I think it will be a big > help. > https://swift.org/migration-guide/se-0107-migrate.html > > -Andy > Thanks Andy, this is great! I hope that over time, even more accessible material is added for newcomers. I still feel I would have a hard time

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

2016-09-07 Thread Jacob Bandes-Storch via swift-users
On Wed, Sep 7, 2016 at 5:54 PM, Michael Ilseman via swift-users < swift-users@swift.org> wrote: > 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

Re: [swift-users] UnsafeMutablePointer Swift 3 conversion

2016-09-03 Thread Jacob Bandes-Storch via swift-users
I was referring to this: let mainPtr : UnsafeMutablePointer = shadowPtr.advanced (by: 1).withMemoryRebound(to: MainPass.self, capacity: 1) {$0} mainPtr.pointee = mainPassFrameData The result of $0 is being returned from the block and used later. cc'ing Andrew Trick on this

Re: [swift-users] UnsafeMutablePointer Swift 3 conversion

2016-09-03 Thread Jacob Bandes-Storch via swift-users
Yikes! That's unsafe! When using withMemoryRebound, I think you're only supposed to use the argument $0 inside the block. Saving it and using it after withMemoryRebound is probably undefined behavior. But maybe you can move your ".pointee = x" into a separate function rather than using a closure?

Re: [swift-users] UnsafeMutablePointer Swift 3 conversion

2016-09-03 Thread Jacob Bandes-Storch via swift-users
Hi Patrice, I don't have a solution for you, but I just wanted to point out what I think may be an error with your use of the new UnsafeRawPointer APIs: constantBufferForFrame.contents().bindMemory(to: ShadowPass.self, capacity: MemoryLayout.size) I believe the `capacity` should actually be the

Re: [swift-users] Is 12:01:00A.M in DataFormatter.localizedString correct?

2016-08-28 Thread Jacob Bandes-Storch via swift-users
12:01 AM is the correct way of writing "one minute past midnight" in 12-hr time. On Sun, Aug 28, 2016 at 9:15 PM, Zhao Xin via swift-users < swift-users@swift.org> wrote: > It should be called 00:01:00 A.M., instead of 12:01:00 A.M. Shouldn't it? > > import Foundation > > > let now = Date() > >

Re: [swift-users] Optional chaining and String properties

2016-08-01 Thread Jacob Bandes-Storch via swift-users
You can think of this like flatMap: let count = s.flatMap { $0.characters.count } ?? 0// like s?.characters.count ?? 0 let count = s.flatMap { $0.characters }.flatMap { $0.count } ?? 0 // like (s?.characters)?.count ?? 0 Jacob On Mon, Aug 1, 2016 at 10:26 AM, Stephen Schaub via

Re: [swift-users] Compact iteration of optional collection?

2016-07-28 Thread Jacob Bandes-Storch via swift-users
You should test it out — I'd guess there's a good chance it gets optimized out. On Thu, Jul 28, 2016 at 2:58 PM Rick Mann wrote: > Yeah, I suppose that works. Feels a bit clunky, like the language lacks > specific support for this (in that it provides specific support for

Re: [swift-users] Compact iteration of optional collection?

2016-07-28 Thread Jacob Bandes-Storch via swift-users
How about "for item in someOptionalContainer ?? []" ? On Thu, Jul 28, 2016 at 2:55 PM, Rick Mann via swift-users < swift-users@swift.org> wrote: > I often call methods that return an optional collection. I then iterate > over it. The problem is, it's a bit cumbersome to write: > > if let

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-18 Thread Jacob Bandes-Storch via swift-users
Shouldn't that be implicit, since the function is `override`? On Mon, Jul 18, 2016 at 5:25 PM, Tony Parker via swift-users < swift-users@swift.org> wrote: > Hi John, > > Can you try this? > > @objc(encodeInt:forKey:) > override func encode(_ intv: Int, forKey key: String) { >

Re: [swift-users] simple i/o on linux with open source swift

2016-07-16 Thread Jacob Bandes-Storch via swift-users
If I've surmised correctly from other messages on this thread, you should be able to `import Glibc` and then you can use most of what's in the C standard library (since Swift interoperates directly with C). The module map which enables you to import Glibc is:

Re: [swift-users] [swift-corelibs-dev] [swift-evolution] WWDC Meetup

2016-06-07 Thread Jacob Bandes-Storch via swift-users
+1 to both points :) On Mon, Jun 6, 2016 at 11:11 PM Javier Soto via swift-corelibs-dev < swift-corelibs-...@swift.org> wrote: > I would love to join as well!! > > I'd like to propose perhaps to plan something alternative to beers to keep > it inclusive to members who may not be 21 or like to

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

2016-05-09 Thread Jacob Bandes-Storch via swift-users
On Mon, May 9, 2016 at 10:25 AM, Joe Groff via swift-users < swift-users@swift.org> wrote: > > > On May 7, 2016, at 10:39 AM, Austin Zheng via swift-users < > swift-users@swift.org> wrote: > > > > Hello Swift users, > > > > I wanted to run something past you folks and get some opinions/feedback.

Re: [swift-users] Trying to learn swift 3 renamification (as mattn calls it!)

2016-04-21 Thread Jacob Bandes-Storch via swift-users
The latter. Check out the docs: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Functions.html#//apple_ref/doc/uid/TP40014097-CH10-ID166 On Thu, Apr 21, 2016 at 3:37 PM, Neil Faiman via swift-users < swift-users@swift.org> wrote: > > > On Apr 21,

Re: [swift-users] Sampling collections

2016-04-10 Thread Jacob Bandes-Storch via swift-users
I encourage anyone thinking about PRNG APIs to check out what C++ STL has to offer: http://en.cppreference.com/w/cpp/numeric/random And this analysis/extension of it: http://www.pcg-random.org/posts/ease-of-use-without-loss-of-power.html Jacob On Sun, Apr 10, 2016 at 6:40 PM, Brent Royal-Gordon

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Jacob Bandes-Storch via swift-users
Oops, of course I meant product(...) ! Jacob On Fri, Dec 18, 2015 at 1:45 PM, Jacob Bandes-Storch wrote: > 1. Maybe ProductGenerator? > 2. Use AnyGenerator<(T, U)>? > > I'd love to see something like this in stdlib: > > func product(s1: S1, s2: S2) -> >

Re: [swift-users] Need better name, want to hide generator

2015-12-18 Thread Jacob Bandes-Storch via swift-users
1. Maybe ProductGenerator? 2. Use AnyGenerator<(T, U)>? I'd love to see something like this in stdlib: func product(s1: S1, s2: S2) -> ProductSequence { ... } where ProductSequence.Generator.Element is (T, U). So your example could