On 31.05.2016 22:37, Chris Lattner wrote:
1) Introduce a new declmodifier named something like “atomiclazy”.
2) Disallow global and static variables, unless they are explicitly marked
atomiclazy (compiler would provide a fixit hint to suggest this).
3) Replace the atomiclazy magic with a property behavior when they exist.

In this model, you’d presumably have the choice about atomiclazy or lazy
when setting up either a static or a local property.

OK, I like this direction. I.e. instead of changing current behavior of static/global variables, we require explicit decoration for them with `atomiclazy` and so their behavior becomes self-documented and it is clear from definition that this behavior is different than just `lazy`. One can't expect that `atomiclazy` is the same as `lazy`.

This appends some complexity to the language to syntax but also add clarity and self-documentation to behavior of defined static/global variables.

As I understand, we need this `atomiclazy` only if static variable has initialization block like here:

class A {
    static atomiclazy var p : Int = {10}()
}

but this will not require atomiclazy :

class A {
    static var p = 10
}

Opinions on this?
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to