Review of first draft John Cowan (20 Apr 2020 14:11 UTC)
Re: Review of first draft Lassi Kortela (20 Apr 2020 15:02 UTC)
Re: Review of first draft Marc Nieper-Wißkirchen (20 Apr 2020 15:19 UTC)
Re: Review of first draft Lassi Kortela (20 Apr 2020 15:35 UTC)
Re: Review of first draft Marc Nieper-Wißkirchen (20 Apr 2020 15:45 UTC)
Loading code from standard input Lassi Kortela (20 Apr 2020 16:01 UTC)
Re: Loading code from standard input Marc Nieper-Wißkirchen (20 Apr 2020 16:30 UTC)
Re: Loading code from standard input Lassi Kortela (20 Apr 2020 16:49 UTC)
Re: Loading code from standard input John Cowan (20 Apr 2020 17:36 UTC)
Re: Loading code from standard input Lassi Kortela (26 May 2020 12:38 UTC)
Re: Loading code from standard input John Cowan (26 May 2020 17:36 UTC)
Re: Loading code from standard input Lassi Kortela (26 May 2020 17:45 UTC)
Re: Loading code from standard input John Cowan (26 May 2020 17:52 UTC)
Re: Loading code from standard input Lassi Kortela (26 May 2020 18:06 UTC)
Re: Loading code from standard input Marc Nieper-Wißkirchen (26 May 2020 18:12 UTC)
Re: Loading code from standard input Lassi Kortela (26 May 2020 18:50 UTC)
Re: Loading code from standard input Vladimir Nikishkin (27 May 2020 07:48 UTC)
Re: Loading code from standard input Lassi Kortela (27 May 2020 08:07 UTC)
Re: Review of first draft John Cowan (20 Apr 2020 16:02 UTC)

Re: Loading code from standard input Lassi Kortela 26 May 2020 12:38 UTC

>      > It is brittle in any case because the "script" being loaded may call
>      > `read' in between.
>
>     True. Perhaps implementations should be required to buffer the whole
>     source code from stdin before reading any of it. Otherwise the results
>     may be "artistic" :)
>
> If everything were buffered when reading from stdin, the REPL would be
> unusable: it would buffer everything you type and when you ^D (or ^Z in
> Windows) only then would you get any output.
>
> Here is a file "dog.scm"
>
> (import (scheme write))
> (import (scheme read))
> (display "Woof woof!\n")
> (display (read))
> "Arf arf!\n"
>
> When I run this with "chibi <foo.scm" it outputs both "Woof woof!" and
> "Arf arf!", along with some Chibi prompts.  When I run it with "chibi
> foo.scm", it outputs "Woof woof!" and waits for me to enter an
> S-expression from the terminal, which is then displayed; the "Arf
> arf!\n" string is read but ignored.

A Scheme implementation should check isatty(STDIN_FILENO) to figure out
whether stdin is a terminal, only running the REPL if it is. If it's not
a terminal, buffer the whole contents and then read from the buffer.
Would there be problems with this arrangement?

The Windows API ought to have an API equivalent to isatty().