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

An I/O idea (good idea) #907

Closed
enty8080 opened this issue Jan 26, 2020 · 5 comments
Closed

An I/O idea (good idea) #907

enty8080 opened this issue Jan 26, 2020 · 5 comments

Comments

@enty8080
Copy link

What are you thinking about making user input easily:

  • Now:
    a = (read-upto "\n")[:-1]
  • Why you don’t want to make it easily:
    a = read()
    ?
@krader1961
Copy link
Contributor

Because

a) your proposal isn't valid elvish syntax,

b) your proposal is less flexible, and

c) a "read line function that discards the trailing newline" is now trivial to write:

fn readline {
    put (read-upto "\n")[:-1]
}

Whether readline would be useful enough to be predefined is unclear.

@enty8080
Copy link
Author

Okey, but what about read builtin? Like read-upto, but without upto with this syntax:
a = (read)
?

@krader1961
Copy link
Contributor

Okey, but what about read builtin?

You've just renamed readline to read. Personally, if people think this would be used often enough to be worth adding to the core implementation I think it should be named readline. Alternatively, a generalized read that also supports displaying a prompt, similar to what @hhanche posted on Gitter, might be worth adding.

@zzamboni
Copy link
Contributor

@enty8080 I actually asked @xiaq about this in the Telegram group:

zzamboni: Any chance to introduce a readline while you are at it? I now am using a wrapper around read-upto "\n", so I hope it should be simple :)

xiaq I'm not sure - while it's a convenience, I'd like to keep the built-in module small
You can just define it as fn read-line { read-upto "\n" }, right?

Which is OK with me. The readline function you propose is trivial to write, like @krader1961 mentioned.

@krader1961
Copy link
Contributor

@xiaq, It seems like this can be closed since commit 5a09222 implemented a read-line command that works regardless whether the platform uses \n or \r\n to terminate lines. See also issue #975.

@xiaq xiaq closed this as completed Jun 15, 2020
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

No branches or pull requests

4 participants