public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Helmut Eller <eller.helmut@gmail.com>, kawa@sourceware.org
Subject: Re: Prompt on read
Date: Tue, 21 Nov 2017 22:49:00 -0000	[thread overview]
Message-ID: <b9109562-725d-0410-fa04-7326faca91b8@bothner.com> (raw)
In-Reply-To: <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/

  reply	other threads:[~2017-11-21 22:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 15:44 Helmut Eller
2017-11-21 22:49 ` Per Bothner [this message]
2017-11-21 23:31   ` Helmut Eller
2017-11-22 21:27     ` Per Bothner
2017-11-22 23:11       ` Helmut Eller
2017-11-26  3:32       ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9109562-725d-0410-fa04-7326faca91b8@bothner.com \
    --to=per@bothner.com \
    --cc=eller.helmut@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).