<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thanks for bringing this up, Nikolai. IMHO it does need a formal proposal because property (and subscript) access can be used in more interesting ways than just calling the getter or setter. In particular, how does this interact with inout? Is there a "rethrows" equivalent? What are the rules for overrides? (That last is probably very straightforward, but it ought to be written out explicitly.)</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 5, 2015, at 19:08, Nikolai Vazquez via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">One of the aspects of Swift that I like is computed properties for structures and classes. It allows for adding logic when obtaining values or for having the returned value be dependent on another.</div><div class=""><br class=""></div><div class="">As of the `ErrorType` protocol introduction in Swift 2, we can throw errors when it comes to functions and initializers. However, this does not apply to getters and setters.</div><div class=""><div class=""><div class=""><br class=""></div><div class=""><div class="">```swift</div><div class="">struct File<Data> {</div><div class=""> var contents: Data {</div><div class=""> get throws { ... }</div><div class=""> set throws { ... }</div><div class=""> }</div><div class="">}</div><div class="">```</div></div></div><div class=""><br class=""></div><div class="">A better example would be getting and setting the current working directory of the process:</div><div class=""><br class=""></div><div class=""><div class="">```swift</div><div class="">import Foundation</div><div class=""><br class=""></div><div class="">extension Process {</div><div class=""> static var workingDirectory: String {</div><div class=""> get {</div><div class=""> let fileManager = NSFileManager.defaultManager()</div><div class=""> return fileManager.currentDirectoryPath</div><div class=""> }</div><div class=""> set throws {</div><div class=""> let fileManager = NSFileManager.defaultManager()</div><div class=""> guard fileManager.changeCurrentDirectoryPath(newValue) else {</div><div class=""> throw Error("...")</div><div class=""> }</div><div class=""> }</div><div class=""> }</div><div class="">}</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">```</div></div><div class=""><br class=""></div><div class=""><br class=""></div></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZEz4qHYnXhPr3bBPu-2FxP4tN3HfWKL-2FtJpqkQ0gkOVSAlg6dL6D3u6hSuneuFUGyvunR-2FOIZKuXb9cfMbGfRXqJKrwq6-2B5PP0FfpFwR4PrXYRe3N-2BdKaAVlSb1xhNl3qNvW6Fl1QALXsuEOOR0EITBR-2BkLZf8urLlqlqnedYv-2BcpIXxabkLwoE4-2FhD1vIjulKHjMhcJeGshykGJQxnVQXV-2B3gjb4mFEGqZy2lx9dsiSk-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>