Pitch: Property Delegates

I don’t like this @ syntax because it doesn’t explicitly name the fact the storage of the property is delegated to or the storage of the property is provided by or from elsewhere. It’s harder to understand and read because the @ is confused with other compiler concepts and it’s harder to explain (express into a sentence of English, say) and teach.

With respect to exposing the storage using the $ syntax, could this be an alternative approach?

public var myProperty: Int from myStorage
private var myStorage: AtomicLazy<Int>()

The idea here is that implementations wanting access to the storage should declare and name a property that provides for another’s storage. Otherwise, the storage remains inaccessible:

public var myProperty: Int from AtomicLazy()

What I like about this is the developer can express that the overall implementation of the type with the property with delegated storage should (or does) not manipulate the storage directly.

2 Likes