[swift-evolution] [RFC] #Self

Chris Lattner clattner at apple.com
Tue May 10 13:42:47 CDT 2016


> On May 10, 2016, at 9:01 AM, Timothy Wood <tjw at me.com> wrote:
> 
> 
>> On May 10, 2016, at 8:56 AM, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>>> 
>>> On May 10, 2016, at 7:50 AM, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> As a compile-time substitution, it could be used in any and all of the examples in your bullet list as a literal text replacement..
>>> 
>>> Quick rundown:
>>> 
>>> struct A {
>>>   ...#Self... // #Self is substituted by A
>>> }
>>> 
>>> class B {
>>>    ...#Self... // Self is substituted by B
>>> }
>>> 
>>> class C {
>>>   ... #Self... // Self is substituted by C, which is the defining type at compile time
>>> }
>> 
>> I think it would be surprising if #Self produced the name of the enclosing static type: Self produces the dynamic type, and we’d want to preserve consistency if it were named #Self.
> 
> 
> I’m not sure I understand this comment -- if #Self should mean the same as Self, why would it get added? My whole point in suggesting #Self was that it mirrored #file and #line in that it was a compile time replacement of some static information.

I think I misunderstood “textual replacement” to mean that #Self returns a string.

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160510/07cb1126/attachment.html>


More information about the swift-evolution mailing list