Re: [swift-users] Is it possible to specify error type thrown in a protocol method

2017-07-05 Thread Tim Wang via swift-users
Thanks Howard, it's a good workaround. Do you think it would be better to be part of swift language feature? I wish swift team could consider this :) On Thu, Jul 6, 2017 at 11:04 AM Howard Lovatt wrote: > You could use a result type, e.g.: > > https://github.com/antitypical/Result > > Or roll y

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Jens Persson via swift-users
On Wed, Jul 5, 2017 at 11:50 PM, Dave Abrahams via swift-users < swift-users@swift.org> wrote: > … > As a name, signum falls into the “term-of-art” category, so at least > that part is in conformance to the guidelines. In specialized areas > like this one, I generally defer to the domain experts,

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Jens Persson via swift-users
On Wed, Jul 5, 2017 at 6:52 PM, Zhao Xin wrote: > For your specific question, `func signum() -> Self` returns `Self`, which > can't be used in property. > `var signum:Self { return self }` will generate an error "'Self' is only > available in a protocol or as the result of a method in a class". >

Re: [swift-users] Is it possible to specify error type thrown in a protocol method

2017-07-05 Thread Howard Lovatt via swift-users
You could use a result type, e.g.: https://github.com/antitypical/Result Or roll your own result type. I think the reason that Swift doesn't support what you want is because of rethrows. When you declare a method as rethrows it can throw anything because the closure it is re-throwing can throw a

[swift-users] Is it possible to specify error type thrown in a protocol method

2017-07-05 Thread Tim Wang via swift-users
Hi Swifters, I am wondering if it is possible to specify error types thrown in a protocol method. By allowing us to do it and letting the compiler check all the implementations of the protocol to make sure only they would only throw the specified error types, we only need to catch our error types

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Dave Abrahams via swift-users
on Wed Jul 05 2017, Jens Persson wrote: > Why is eg the BinaryInteger.signum() a method and not a computed property? > > public protocol BinaryInteger … { > /// Returns `-1` if this value is negative and `1` if it's positive; > /// otherwise, `0`. > /// > /// - Returns: The sign

Re: [swift-users] [swift-evolution] Request for information about constrained protocol inheritance

2017-07-05 Thread Alex Martini via swift-users
Since you mentioned not finding documentation, here's the new section in "The Swift Programming Language": Associated Types with a Generic Where Clause https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Generics.html#//apple_ref/doc/uid/TP400140

Re: [swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Zhao Xin via swift-users
For me, a noun is a property, a verb is a method. So `foo` is a property, `calculateFoo()` is a method. For your specific question, `func signum() -> Self` returns `Self`, which can't be used in property. `var signum:Self { return self }` will generate an error "'Self' is only available in a proto

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

2017-07-05 Thread David Baraff via swift-users
> func decodeMe(_ payload:Any) -> T? { > if let dt = T.self as? DecodableFromAny { > return type(of: dt).fromAny(payload) as! T > } else { > return payload as? T > } > } Auggh! I only thought it worked. Luckily, I had help. My 16 year-old son looked at this code,

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

2017-07-05 Thread David Baraff via swift-users
> On Jul 4, 2017, at 5:48 PM, Jacob Bandes-Storch wrote: > > 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) > } >

[swift-users] Design guidelines for computed property vs no-arg method

2017-07-05 Thread Jens Persson via swift-users
Why is eg the BinaryInteger.signum() a method and not a computed property? public protocol BinaryInteger … { /// Returns `-1` if this value is negative and `1` if it's positive; /// otherwise, `0`. /// /// - Returns: The sign of this number, expressed as an integer of the same

Re: [swift-users] Disable "indexing while building" in Xcode9 (unknown argument: `-index-store-path`)

2017-07-05 Thread Jens Persson via swift-users
I did not file radars for them, as they seem so flagrant. I have to draw the line somewhere or my entire working days would be spent filing radars (including isolating the issues and coming up with good descriptions of them in english, collecting crash logs etc, etc). Reporting less obvious Swift

Re: [swift-users] Disable "indexing while building" in Xcode9 (unknown argument: `-index-store-path`)

2017-07-05 Thread Alex Blewitt via swift-users
Did you file radars for the below? If others have already reported it, then yours will count as a dupe towards it, and the more dupes that a specific radar has the higher visibility it has. Alex > On 5 Jul 2017, at 10:37, Jens Persson wrote: > > I'm using Xcode 9 beta 2 (on Sierra 10.12.5) an

Re: [swift-users] Disable "indexing while building" in Xcode9 (unknown argument: `-index-store-path`)

2017-07-05 Thread Jens Persson via swift-users
I'm using Xcode 9 beta 2 (on Sierra 10.12.5) and my top 3 annoyances are: 1. Having to manually scroll the text editor sideways to follow the caret/cursor as it moves out of view (!) while editing a line that is wider than the text editor. 2. Non-working "File -> Add Files" (Options: Copy items i

Re: [swift-users] New books

2017-07-05 Thread Nimesh Neema via swift-users
Hi Bill, Do you mean Swift 4.0? Matt Neuburg has regularly released a book on iOS Programming Fundamentals since iOS 4.0, with an in-depth coverage of language, core-frameworks and tooling. There's a high probability Matt is already authoring a book on Xcode 9.0 (Xcode version with support for S

Re: [swift-users] Disable "indexing while building" in Xcode9 (unknown argument: `-index-store-path`)

2017-07-05 Thread Alex Blewitt via swift-users
A workaround is to add SWIFT_INDEX_STORE_ENABLE=NO as a build time setting in Xcode, which prevents this argument being added to the call to swiftc. > On 5 Jul 2017, at 02:02, Anders Hasselqvist via swift-users > wrote: > > Hi, > > I've been trying to use the swift4 snapshot toolchains with

Re: [swift-users] [swift-evolution] Request for information about constrained protocol inheritance

2017-07-05 Thread Jens Persson via swift-users
Ah, thanks! Do you happen to know of any particular std lib protocol of the form: protocol P : OtherP where OtherP.AT ... ? On Wed, Jul 5, 2017 at 7:53 AM, Xiaodi Wu wrote: > Replying to swift-users as well, as it's probably the more appropriate > forum. > > SE-0142 (Permit where clauses to cons