I went ahead and prototyped support for using property delegates via attribute syntax. Essentially, this means that one would write:
@Lazy var x = 10
@UserDefault(key: "FOO_FEATURE_ENABLED", defaultValue: false)
static var isFooFeatureEnabled: Bool
which is equivalent to the current proposal's
var x = 10 by Lazy
static var isFooFeatureEnabled: Bool
by UserDefault(key: "FOO_FEATURE_ENABLED", defaultValue: false)
There are some restrictions that come with this design: we no longer have syntactic space for the by private
/ by public
part of the feature. On the other hand, it dovetails with the discussion of custom attributes. I'll bring up the general idea over there.
Doug