[swift-dev] Breaking change in lexing operators next to comments

Chris Lattner clattner at apple.com
Tue Dec 15 01:10:40 CST 2015


> On Dec 14, 2015, at 9:51 PM, Simon Pilkington <simonmpilkington at icloud.com> wrote:
> 
> It seems to make more sense to treat comments as this if they are not present.
> 
> As a related question, should the presence/absence of whitespace be important at all? It seems fragile if it is.

The current design depends on whitespace to decide whether an operator is infix, postfix, or prefix.  It can be surprising to some folks when they first encounter it, but IMO it encourages more maintainable code to be written.

The one thing that I’d love to see fixed is to enhance the error produced for things like:

	let x = y*-z

to produce a fixit, which rewrites it as:

	let x = y * -z

-Chris


More information about the swift-dev mailing list