[Review] SE-0030 Property Behaviors


(Thorsten Seitz) #1

Ah, you are right, of course! I was thinking of annotations with a name for XML- or JSON-Mapping. Wrong track of thought… :slight_smile:

-Thorsten

···

Am 19. Februar 2016 um 08:05 schrieb Curt Clifton curt@curtclifton.net:

Besides eliminating the odd naked “declaration”, this has the added advantage that it could be extended to bind initialValue, propertyName. :slight_smile:

Couldn’t we just add a name by introducing an accessor to be implemented by the user of a property?
On Feb 18, 2016, at 10:09 PM, Thorsten Seitz tseitz42@icloud.com wrote:

What would that look like? Would the programmer have to give the name of the property twice? Like so:

@plistBacked var warningTextColor: NSColor {
 name {
 return warningTextColor
 }
}

While that works as a stop gap, the repetition is an invitation to error. It would be much better to just write:

@plistBacked var warningTextColor: NSColor

and make the property’s name available to the behavior’s implementation, much as the property’s declaring type is exposed as self.

But this is also largely off-topic for the thread. I was arguing for a better way to declare that initialValue should be bound and suggesting that a bind construct might be an approach that is extensible in the future.

Cheers,

Curt