[Pitch] Instance var/let property as type member could be unbound function

That is, given

     extension Int : CustomStringConvertible {
       var description: Swift.String {
         get {}
       }
     }

my proposal is to expose

     Int.description

as a function with type

     (Int) -> String

This would make var/let properties behave more similarly to func properties, where given

extension Int : PartOfRandomAccessIndexType {
   func successor() -> Swift.Int
}

we have

     Int.successor

exposed with type

     (Int) -> () -> Int

Making var/let properties behave "the same" looks more consistent to me, but that's as a naive Swift user with no real compiler/language-design experience. For the same reason I can't see whether this would impact the ABI, whether it's remotely feasible, and even whether what looks like "the same" behaviour to me is *really* semantically equivalent. So if there is some interest in this idea I'd be happy to work up a formal proposal, but I thought I would test the waters first.

Cheers,
Tikitu

···

--
http://www.logophile.org/
@tTikitu

+1. This would be very nice to have when dealing with computed properties.

···

--
Richard

On Mar 4, 2016, at 1:24 AM, Tikitu de Jager via swift-evolution <swift-evolution@swift.org> wrote:

That is, given

   extension Int : CustomStringConvertible {
     var description: Swift.String {
       get {}
     }
   }

my proposal is to expose

   Int.description

as a function with type

   (Int) -> String

This would make var/let properties behave more similarly to func properties, where given

extension Int : PartOfRandomAccessIndexType {
func successor() -> Swift.Int
}

we have

   Int.successor

exposed with type

   (Int) -> () -> Int

Making var/let properties behave "the same" looks more consistent to me, but that's as a naive Swift user with no real compiler/language-design experience. For the same reason I can't see whether this would impact the ABI, whether it's remotely feasible, and even whether what looks like "the same" behaviour to me is *really* semantically equivalent. So if there is some interest in this idea I'd be happy to work up a formal proposal, but I thought I would test the waters first.

Cheers,
Tikitu

--
logophile | Main / Welcome @tTikitu
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.swift.org_mailman_listinfo_swift-2Devolution&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Ezje1IF3xGXfUMfsj4fBc7oM7BcJys1dhQ6psfXzLMU&m=fhXGdPVgIvFmabL5VwojkDaC2y5kpJuJHE_JZpMectU&s=TScYfkqqnKKQN9qKCwAjV3FO2TuNl69Yk61Ad6L8EMY&e=