[swift-evolution] [Proposal] Property behaviors
Chris Lattner
clattner at apple.com
Wed Jan 13 23:37:20 CST 2016
> On Jan 13, 2016, at 9:35 PM, Chris Lattner <clattner at apple.com> wrote:
>
>
>> On Jan 13, 2016, at 6:02 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>>
>>> Relatedly: How first-class are behaviors? Can you assign `foo.bar.lazy` to a variable, or pass it as a parameter? Or can you pass a value along with its behavior?
>>>
>>> func consumeThing(inout thing: [resettable] Thing) {
>>> thing.use()
>>> thing.resettable.reset()
>>> }
>>
>> That's an interesting idea; I think we could add something like that later if it's useful. It's my intent in this proposal to avoid treating behaviors as first-class types and keep them mostly instantiation-based, in order to avoid the metadata instantiation overhead of a type-based approach. That would mean that `bar.lazy` isn't really a first-class entity.
>
> Random point, if bar.lazy isn’t a first class thing, then that reinforces Talin’s syntax idea of bar.[lazy].reset() as the syntax to operate on the behavior. It would be nice to move towards a model where all simply-dotted things are curryable.
Sorry, I meant Tal Atlas’ idea.
-Chris
More information about the swift-evolution
mailing list