[swift-evolution] Proposal: Re-instate mandatory self for accessing instance properties and functions (David Hart)

Chris Lattner clattner at apple.com
Tue Dec 15 23:54:51 CST 2015


> On Dec 15, 2015, at 8:10 PM, Kenny Leung via swift-evolution <swift-evolution at swift.org> wrote:
> 
> This is the full text of what Chris said in regard to “Proposal: Add Flags to Disable [Optional] Conversions"
> 
>> I don’t like the idea of having different incompatible dialects, and behavior changing modes.  That said, I’m personally not opposed to providing functionality that would enable people to use a reduced subsets of the language, and have the compiler enforce it.  For example, I don’t have a problem with someone saying they never want to use the x!, as!, try! family and have the compiler tell them if they do.
>> 
>> To relate this to your question, I’d be fine with functionality that causes the compiler to produce an error when code requires an implicit conversion, but I wouldn’t want them to be just “disabled”, because I think this could change the interpretation of valid swift code (in admittedly weird cases).
>> 
>> In terms of how to express this, I’m not in love with modal compiler flags :-).  I’d much rather this sort of requirement be specified as a pragma-like construct that applies to an arbitrary scope (e.g. class or function body) or a whole file.  This keeps the code self describing.
> 
> I think the mandatory self problem is analogous to never wanting to use x!, as! or try!. If you restrict yourself to always using self.whatever, it is not unusual to someone else, and if they leave off the compiler flag or pragma that enforces this, the code will still compile.

I agree with you.

-Chris


More information about the swift-evolution mailing list