[swift-evolution] Two thoughts on concurrency

Chris Lattner clattner at nondot.org
Thu Aug 24 23:29:07 CDT 2017


> On Aug 24, 2017, at 9:17 PM, Félix Cloutier <felixcloutier at icloud.com> wrote:
> 
> I feel that it's important to point out that this example feels weird because even though the compiler doesn't treat "weak" as a reserved term, most developers perceive it as one. I don't think that David is worried that we're taking away all the cool words from the realm of identifiers; the problem is that "technically not a keyword" is a qualifier mostly distinct from "not perceived as a keyword". Even if attributes don't live in the same token namespace as identifiers as far as the compiler is perceived, I'd argue that they add about the same complexity (or more) to the mental model that developers have to have about the language.

Obviously details matter here, but there is an important time and place to introduce a “conceptual” keyword: it is when there is an important and distinct concept that needs to be thought about by the humans that interact with the code.

In the proposal “actor” vs “distributed actor” is one of those really important distinctions, which is why (IMO) it deserves the “complexity” of a new identifier.  It isn’t the identifier that adds the complexity, it is the expansion of the language surface that the identifier designates.

-Chris




> Félix
> 
>> Le 24 août 2017 à 20:58, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> a écrit :
>> 
>> 
>>> On Aug 24, 2017, at 8:57 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> On Aug 24, 2017, at 1:59 PM, Dave DeLong via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> Keyword Explosion
>>>> 
>>>> During the Great Access Control Wars of Swift 4, one of the points that kept coming up was the reluctance to introduce a bazillion new keywords to address all the cases that were being brought up. The impression I got is that adding new keywords was essentially an anti-pattern. And so when I’m reading through this onslaught of emails, I’m troubled by how everything is seeming to require new keywords. There’s the obvious async/await, but there’s also been discussion of actor, reliable, distributed, behavior, message, and signal (and I’ve probably missed others).
>>> 
>>> I can’t speak for message/signal, but you need to understand a bit more about how Swift works.  There is a distinction between an actual keyword (which ‘async’ would be, and ‘class’ currently is) and “modifiers”.  Modifiers occur with attributes ahead of a real keyword, but they are not themselves keywords.  They are things like weak, mutating, reliable, distributed, etc.  If we go with the “actor class” and “actor func” approach, then actor would not be a keyword.
>> 
>> Concrete example, this is (weird but) valid code:
>> 
>> var weak = 42
>> weak += 2
>> print(weak+weak)
>> 
>> 
>> This is a consequence of weak not being a keyword.
>> 
>> -Chris
>> 
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170824/2fea4e46/attachment.html>


More information about the swift-evolution mailing list