Lexer advance()



Using Version 7.3.1 (7D1014) of Xcode gives a warning ‘++ is deprecated & will be removed in Swift 3’ for the ++position statement in the advance() function. Eek! Using instead position.advancedBy(1) gave an almighty crash, but using position = position.successor() seemed to work. I guess the second edition of the book will be Swift 3 compatible (with free upgrades for all those who bought the first edition, hint, hint… :smiley: ).


Notice the implicitly unwrapped expression of alarm there…


This one irks me. The general rule has been to switch to += to replace ++, but you can’t do it for String.characterView.Index. What is the official word on Swift 3.0 compat for cases like this?


I’m currently running Xcode v. 8.0 beta 3, which supports Swift 3. Not only is a statement like
deprecated, but also a statement like
position = position.successor()
is not allowed, as, according to Swift 3 Proposal: SE-0065, “responsibility for index traversal is moved from the index to the collection itself.” See that accepted proposal here:
A New Model for Collections and Indices

Hence, the increment for position becomes
position = input.index(after: position)

(I assume this is correct as it is not flagged as an error in the Playground. Can the authors verify this, please?)