rxi / fe

A tiny, embeddable language implemented in ANSI C
MIT License
1.31k stars 82 forks source link

Handling user input? #9

Closed eli-oat closed 3 years ago

eli-oat commented 3 years ago

Firstly, I fully confess that I'm totally inept when it comes to writing C, so the answer here may very well to be to extend fe -- but I'm wondering about the best way to pass user input into a program written in fe -- either by pipe or by prompting for user input.

eli-oat commented 3 years ago

A way to re-frame this question would be: is there a way to load a script from the repl, akin to common lisp's (load "file-name")

jminor commented 3 years ago

I don't see a way to do it currently, but you could implement a load and/or eval feature as the inverse of the existing print feature. If you search for P_PRINT in fe.c and then look at the main function you can maybe see how this could be implemented.

eli-oat commented 3 years ago

Thanks @jminor this is very helpful.

I've been exploring ways to port do-file from aq, but I think your suggestion is a better tack.

eli-oat commented 3 years ago

At this point I have a workable direction, but haven't gotten it to work, yet. Going to close this since I'm relatively confident that this functionality is already there, I just need to sort out how to get it working.