[swift-evolution] [Concurrency] async/await + actors

Chris Lattner clattner at nondot.org
Thu Aug 17 20:59:33 CDT 2017


> On Aug 17, 2017, at 5:47 PM, William Jon Shipley <wjs at delicious-monster.com> wrote:
> 
> I think the comments on “prettify()” are from an earlier version of the sample code? The way it’s called it doesn’t look like it’d access theList at all.

The body of the function is omitted :-)

The idea of the goofy example is that it walks through theList to see if the existing entries are capitalized.  If so, it capitalizes the string, if not it returns the string unmodified.

-Chris



> 
>   actor TableModel {
>     let mainActor : TheMainActor
>     var theList : [String] = [] {
>       didSet {
>         mainActor.updateTableView(theList)
>       }
>     }
>     
>     init(mainActor: TheMainActor) { self.mainActor = mainActor }
> 
>     // this checks to see if all the entries in the list are capitalized:
>     // if so, it capitalize the string before returning it to encourage
>     // capitalization consistency in the list.
>     func prettify(_ x : String) -> String {
>       // ... details omitted, it just pokes theList directly ...
>     }
> 
>     actor func add(entry: String) {
>       theList.append(prettify(entry))
>     }
>   }
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170817/633244c9/attachment.html>


More information about the swift-evolution mailing list