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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file/lines iterator #1157

Merged
merged 2 commits into from
May 26, 2023
Merged

Add file/lines iterator #1157

merged 2 commits into from
May 26, 2023

Conversation

zevv
Copy link
Contributor

@zevv zevv commented May 24, 2023

That's what you get for coming up with a nice implementation. Still trying to get this into the stdlib 馃槃

Copy link
Contributor

@primo-ppcg primo-ppcg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to reiterate my objections here.

I agree that this would be a useful additon, in particular to iterate lines of stdin as a command line tool. However, every other file/* function requires a valid file descriptor as its argument, and I don't agree that this function is special enough or important enough to be an exception.

(defn file/lines
  "Return an iterator over the lines of a file."
  [file]
  (coro
    (while (def line (file/read file :line))
      (yield line))))

I think this is a sufficient implementation.

@zevv
Copy link
Contributor Author

zevv commented May 26, 2023

@primo-ppcg I must admit you make a compelling argument there, I agree.

PR changed to drop accepting a file name.

@bakpakin bakpakin merged commit 70f13f1 into janet-lang:master May 26, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants