Hello,
Other Schemes (like Chicken, Ypsilon, Larceny, and Ikarus) will read from stdin by default. For example:
echo '(+ 1 1)' | csi
However, this doesn't work with 'gsi'. Is there a way to get this to work?
Ed
Afficher les réponses par date
Eduardo Cavazos wayo.cavazos@gmail.com writes:
Hello,
Other Schemes (like Chicken, Ypsilon, Larceny, and Ikarus) will read from stdin by default. For example:
echo '(+ 1 1)' | csi
However, this doesn't work with 'gsi'. Is there a way to get this to work?
$ echo '(println (+ 1 1))' | gsi /dev/stdin
Eduardo Cavazos wayo.cavazos@gmail.com writes:
Other Schemes (like Chicken, Ypsilon, Larceny, and Ikarus) will read from stdin by default. For example:
echo '(+ 1 1)' | csi
However, this doesn't work with 'gsi'. Is there a way to get this to work?
Alex Shinn wrote:
$ echo '(println (+ 1 1))' | gsi /dev/stdin
Thanks Alex.
Is there a way to get gsi/gsc to start a REPL which reads from stdin? This is not quite the same:
gsi /dev/stdin -
That will read from stdin till EOF and then start a REPL.
I'm guessing that the fact that the gsi/gsc REPL doesn't read from stdin by default has to do with the elaborate console it comes with. Seems like there should be a way to turn that off with an option; i.e. get a plain old stdin repl.
Ed
On 16-Apr-09, at 5:54 AM, Eduardo Cavazos wrote:
Eduardo Cavazos wayo.cavazos@gmail.com writes:
Other Schemes (like Chicken, Ypsilon, Larceny, and Ikarus) will read from stdin by default. For example:
echo '(+ 1 1)' | csi
However, this doesn't work with 'gsi'. Is there a way to get this to work?
Alex Shinn wrote:
$ echo '(println (+ 1 1))' | gsi /dev/stdin
Thanks Alex.
Is there a way to get gsi/gsc to start a REPL which reads from stdin? This is not quite the same:
gsi /dev/stdin -
That will read from stdin till EOF and then start a REPL.
I'm guessing that the fact that the gsi/gsc REPL doesn't read from stdin by default has to do with the elaborate console it comes with. Seems like there should be a way to turn that off with an option; i.e. get a plain old stdin repl.
You are correct. By default REPLs are started on the "console" (the controlling terminal, or /dev/tty, in UNIX). This is a "good thing" so that programs which read/write on stdin/stdout can be debugged (single-stepping, etc).
The runtime option -:d- will do what you want, i.e. start REPLs on stdin/stdout (and it also means that inside the REPLs current-in/ output-port will refer to stdin/stdout instead of the console). Of course if you do this the REPL interaction and the program's I/O on the current-in/output-port will be mixed.
Here are a few examples which I hope will be enlightening:
% gsi Gambit v4.4.2
(pp (current-input-port))
#<input-output-port #2 (console)>
,q
% echo '(pp (current-input-port))' | gsi -:d- Gambit v4.4.2
#<input-port #2 (stdin)>
*** EOF again to exit
% echo '(pp (current-input-port))' | gsi -e '(eval (read))' #<input-port #2 (stdin)>
% echo '(sin 1)' | gsi -:ds -e '(eval (read))' *** STOPPED IN (string)@1.2
,s
| > eval | #<procedure #2 eval> *** STOPPED IN (string)@1.8
,s
| > read | #<procedure #3 read> *** STOPPED IN (string)@1.7
,s
| > (read) | (sin 1) *** STOPPED IN (string)@1.1
,s
| > (eval (read)) *** STOPPED
,s
| | > sin | | #<procedure #4 sin> *** STOPPED
,s
| | > 1 | | 1 *** STOPPED
,s
| | > (sin 1) | | .8414709848078965 | .8414709848078965
Marc
Marc Feeley wrote:
The runtime option -:d- will do what you want, i.e. start REPLs on stdin/stdout (and it also means that inside the REPLs current-in/output-port will refer to stdin/stdout instead of the console). Of course if you do this the REPL interaction and the program's I/O on the current-in/output-port will be mixed.
Here are a few examples which I hope will be enlightening:
Thanks Marc!