[swift-evolution] [RFC] #Self

Timothy Wood tjw at me.com
Tue May 10 17:59:57 CDT 2016


> On May 10, 2016, at 3:53 PM, Matthew Johnson <matthew at anandabits.com> wrote:
> 
> 
> Ahh, this is different than what I have been talking about as it statically evaluates at the call site rather than the declaration site.  Sorry, I think I missed your earlier post.

This would be no different from #file or #line in a default argument position, I think. If you use it in normal code:

	let cls = #Self

it would evaluate as we’ve been discussing elsewhere here. I have had cases though, where using in a default parameter slot would be useulf (assuming it evaluates like #file and #line in those cases).


> One question about this - how would it work if this method was called in a lexical con txt without an enclosing type declaration?  Would that be an error or would it just require a parameter to be passed?

I would expect it to be an error if there were no enclosing type and the parameter wasn’t specified (but yeah, passing an explicit type should work).

> If we call what I am talking about Type and we also want this behavior we should call it #Type as it would be the static type at the call site.  But they are separate ideas and should be separate proposals.

Again, this would only be the case in a default argument position; it would work just like the other “#” symbols.

-tim



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


More information about the swift-evolution mailing list