-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the return type of TokenList's prev
/next
to Option[Token]
#517
Comments
I have this one implemented already but will wait until #534 (hopefully) gets merged. |
@marcelocenerine I am afraid changing the signature is a breaking change that I'd like to avoid. I personally also like the current semantics since I use it regularly to do quick guards + case lf @ Token.LF() if ctx.tokenList.prev(lf).is[Token.Comma] =>
in #537 What do you think about adding instead |
@olafurpg that's true :(. If you want to avoid that and like the current semantics, then let's keep them as is. |
I agree, I'm hesitant to add I opened #539 to add a docstring to next/prev. Please take a look to see if the docstring can be clearer. |
The
prev
/next
methods inTokenList
return the input token if it is the head or last element of the tokenList:In order to identify when a tokenList has run out of tokens while traversing it using
prev
ornext
, users must check whether the returned value is the same object passed as input, which is not a pretty standard thing in Scala libraries and can cause confusion. Maybe it would be clearer if those methods returnedOption[Token]
instead:The text was updated successfully, but these errors were encountered: