grain-lang / grain

The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
https://grain-lang.org/
GNU Lesser General Public License v3.0
3.23k stars 115 forks source link

stdlib: Add `input` function #2074

Open spotandjake opened 3 months ago

spotandjake commented 3 months ago

In python there is the input function which makes reading inputs syncronously from the command line super easy. This helps to position python in an especially useful place for learning to program and writing simple interactive programs. It would be great if we could add a function like this, currently this behaviour could be done through stdin but exposing a nice user friendly function would greatly help with developer experience.

I think the desired type for this would be input(prompt="") => string, if we ever get async capabilities in grain, it would also be great if this was an async function.

We may want to consider adding some sort of console library that contains functions like this and possibly additional printing utils like printTable.

ospencer commented 3 months ago

Requires #1583

ospencer commented 3 months ago

I also agree that this should be in its own library, including things like readLine, etc.