Skip to content
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

read-cdot consumes whitespace after everything even when there is no dot #1454

Closed
AlexKnauth opened this issue Sep 7, 2016 · 4 comments
Closed
Labels
bug Something isn't working correctly

Comments

@AlexKnauth
Copy link
Member

I would expect this program to return #\newline just as it does without read-cdot turned on.

#lang racket
(parameterize ([read-cdot #true])
  (define in (open-input-string "a\n    b"))
  (read in)
  (read-char in))

But instead it returns #\b. Should the read-cdot-true reader be changed to peek through whitespace instead of consuming it?

@samdphillips
Copy link
Contributor

This is the documented behavior.
https://docs.racket-lang.org/reference/reader.html?q=read-cdot#%28part._parse-cdot%29

Finally, after reading any datum x, the reader will seek through whitespace and comments and look for zero or more sequences of a . followed by another datum y.

@jackfirth
Copy link
Sponsor Contributor

The "seek through whitespace" bit doesn't imply to me that the input is consumed even if no dots are found. I would expect it to do what Alex is suggesting: peek ahead and only consume if it actually finds dots.

@jackfirth jackfirth added the bug Something isn't working correctly label Aug 19, 2020
@samdphillips
Copy link
Contributor

Peeking through the history @AlexKnauth is the one who wrote the doc (17db8e5) so they have a better grasp on this than me :)

@mflatt
Copy link
Member

mflatt commented May 15, 2021

I'm going to improve the documentation to replace "seek through" with "consume". Peeking arbitrarily far in a stream is not a great property for a parser, and I don't think we should introduce that behavior.

@mflatt mflatt closed this as completed in 528f344 May 15, 2021
maueroats pushed a commit to maueroats/racket that referenced this issue Jun 17, 2021
maueroats pushed a commit to maueroats/racket that referenced this issue Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants