[idea] errors in properties

I’ll just cut to the chase:
Why is throwing from get, set, willSet and didSet disallowed?

var login: String {
  willSet throws {
    guard newValue.count > 5 else {
      throw LoginError.loginTooSmall
    }
  }
}

try login = “JebediahKerman” // totally fine
try login = “Bob” // throws `LoginError.loginTooSmall`

I’d give my +1 to support this as I’ve wished at one time or another that I could throw in the get, set, willSet, or didSet.

Would this be something a proposal should be written up for when the Swift 5 reviews begin?

···

On Jul 25, 2017, at 2:55 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote:

There have been a number of discussions on the list in this—Google finds a number of these with a search “swift throwing properties site:lists.swift.org <http://lists.swift.org/&gt;”\.

The “tldr” seems to be that it’s not supported because no one has written code to support it yet.
On Tue, Jul 25, 2017 at 15:29 Gor Gyolchanyan via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I’ll just cut to the chase:
Why is throwing from get, set, willSet and didSet disallowed?

var login: String {
  willSet throws {
    guard newValue.count > 5 else {
      throw LoginError.loginTooSmall
    }
  }
}

try login = “JebediahKerman” // totally fine
try login = “Bob” // throws `LoginError.loginTooSmall`

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

There have been a number of discussions on the list in this—Google finds a
number of these with a search “swift throwing properties site:
lists.swift.org”.

The “tldr” seems to be that it’s not supported because no one has written
code to support it yet.

···

On Tue, Jul 25, 2017 at 15:29 Gor Gyolchanyan via swift-evolution < swift-evolution@swift.org> wrote:

I’ll just cut to the chase:
Why is throwing from get, set, willSet and didSet disallowed?

var login: String {
willSet throws {
guard newValue.count > 5 else {
throw LoginError.loginTooSmall
}
}
}

try login = “JebediahKerman” // totally fine
try login = “Bob” // throws `LoginError.loginTooSmall`

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

This sounds like a challenge :slightly_smiling_face:
But seriously, seems like straight-up implementing the feature and then wondering whether or not the pull request will be merged in or rejected is an unnecessary gamble, which is why swift-evolution exists.
Haven’t anyone tried to make a proposal for this?
I’d gladly look into implementing it myself if I new for sure that my efforts wouldn’t be wasted.

···

On Jul 25, 2017, at 11:55 PM, Xiaodi Wu <xiaodi.wu@gmail.com> wrote:

There have been a number of discussions on the list in this—Google finds a number of these with a search “swift throwing properties site:lists.swift.org <http://lists.swift.org/&gt;”\.

The “tldr” seems to be that it’s not supported because no one has written code to support it yet.
On Tue, Jul 25, 2017 at 15:29 Gor Gyolchanyan via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I’ll just cut to the chase:
Why is throwing from get, set, willSet and didSet disallowed?

var login: String {
  willSet throws {
    guard newValue.count > 5 else {
      throw LoginError.loginTooSmall
    }
  }
}

try login = “JebediahKerman” // totally fine
try login = “Bob” // throws `LoginError.loginTooSmall`

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

Brent Royal-Gordon has written a draft proposal:

<https://github.com/apple/swift-evolution/pull/218&gt;

···

On 25 Jul 2017, at 21:58, Gor Gyolchanyan via swift-evolution <swift-evolution@swift.org> wrote:

This sounds like a challenge :slightly_smiling_face:
But seriously, seems like straight-up implementing the feature and then wondering whether or not the pull request will be merged in or rejected is an unnecessary gamble, which is why swift-evolution exists.
Haven’t anyone tried to make a proposal for this?
I’d gladly look into implementing it myself if I new for sure that my efforts wouldn’t be wasted.

On Jul 25, 2017, at 11:55 PM, Xiaodi Wu <xiaodi.wu@gmail.com <mailto:xiaodi.wu@gmail.com>> wrote:

There have been a number of discussions on the list in this—Google finds a number of these with a search “swift throwing properties site:lists.swift.org <http://lists.swift.org/&gt;”\.

The “tldr” seems to be that it’s not supported because no one has written code to support it yet.
On Tue, Jul 25, 2017 at 15:29 Gor Gyolchanyan via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I’ll just cut to the chase:
Why is throwing from get, set, willSet and didSet disallowed?

var login: String {
  willSet throws {
    guard newValue.count > 5 else {
      throw LoginError.loginTooSmall
    }
  }
}

try login = “JebediahKerman” // totally fine
try login = “Bob” // throws `LoginError.loginTooSmall`

Brent Royal-Gordon has written a draft proposal:

<https://github.com/apple/swift-evolution/pull/218&gt;

I totally love it! I’m even OK with wrapping stored properties into computed ones because of willSet and didSet not being able to throw (for the time being anyway).

Brent, hello!
Can you tell me why this proposal of yours is not pushed to review?

···

On Jul 26, 2017, at 8:21 AM, Ben Rimmington <me@benrimmington.com> wrote:

On 25 Jul 2017, at 21:58, Gor Gyolchanyan via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

This sounds like a challenge :slightly_smiling_face:
But seriously, seems like straight-up implementing the feature and then wondering whether or not the pull request will be merged in or rejected is an unnecessary gamble, which is why swift-evolution exists.
Haven’t anyone tried to make a proposal for this?
I’d gladly look into implementing it myself if I new for sure that my efforts wouldn’t be wasted.

On Jul 25, 2017, at 11:55 PM, Xiaodi Wu <xiaodi.wu@gmail.com <mailto:xiaodi.wu@gmail.com>> wrote:

There have been a number of discussions on the list in this—Google finds a number of these with a search “swift throwing properties site:lists.swift.org <http://lists.swift.org/&gt;”\.

The “tldr” seems to be that it’s not supported because no one has written code to support it yet.
On Tue, Jul 25, 2017 at 15:29 Gor Gyolchanyan via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I’ll just cut to the chase:
Why is throwing from get, set, willSet and didSet disallowed?

var login: String {
  willSet throws {
    guard newValue.count > 5 else {
      throw LoginError.loginTooSmall
    }
  }
}

try login = “JebediahKerman” // totally fine
try login = “Bob” // throws `LoginError.loginTooSmall`