This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Prompt on read
- From: Per Bothner <per at bothner dot com>
- To: Helmut Eller <eller dot helmut at gmail dot com>, kawa at sourceware dot org
- Date: Tue, 21 Nov 2017 23:48:54 +0100
- Subject: Re: Prompt on read
- Authentication-results: sourceware.org; auth=none
- References: <m2zi7f3ach.fsf@caladan>
On 11/21/2017 04:44 PM, Helmut Eller wrote:
Am I the only who finds it confusing that the read procedure
automatically writes a prompt? E.g.
#|kawa:1|# (read)
#|kawa:2|# abc
abc
#|kawa:2|#
The read procedure does not write a prompt.
However, when you read from an "interactive port" (implemented using TtyInPort,
when a new line is requested, a prompt is printed.
In other words, in Kawa it's not the REPL that prints the prompt,
but the port itself.
This has the advantage that multi-line input commands get multiple =prompts,
which I think is the correct behavior.
Despite that the prompt in line two is confusing, the line number in the
third prompt seems wrong. I would expect that read works basically like
read-line,
Yes and no. read reads an S-expression, and there may be a many-to-many
relationship between S-expressions and lines. A prompt is printed before
each input line - however note it is possible for a procedure to change the
prompt, for example to the empty string.
I agree there does appear to be some mismatch between when a line number
is incremented and a prompt is printed. This is at least ugly.
I haven't looked into why that happens.
FWIW I can't come up with any valid use-case for explicitly calling read on an
interactive port. The problem is error recovery. Enlighten me.
--
--Per Bothner
per@bothner.com http://per.bothner.com/