Closed PaperPrototype closed 3 years ago
Just add a native function that reads from stdin within your language of choice? Unless you wanna reinvent the wheel and interact with very low level (not to mention platform specific) kernel-mode APIs
You can check my (quite bad actually) implementation of clox in Nim here (check out natReadLine
inside src/stdlib.nim
)
Cheers!
Just add a native function that reads from stdin within your language of choice?
This is the answer. There's really nothing technically interesting about adding support for user input, which is why I omitted it from the book. All you need is a native function like input()
that reads from stdin and returns the result.
@munificent If its so simple why exclude it from the book :P
@nocturn9x Thanks!
@munificent If its so simple why exclude it from the book :P
As bob mentioned, there's nothing special about doing that. No design challenge, no interesting coding technique, it's just literally a function that reads from standard input
Or at least some pointers to as to how to implement it? Or mayeb some external resources that we can look at :)
It would make the book very useful, because aside from making a cool language, we could actually make something useful.
I'm not saying the book is bad, it's just I can't see how not adding input is a good idea (aside from making the book shorter.
I mean, your book is a great starting point, but I want to make something... real.