[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with trailing comment in repl
From: |
Noah Lavine |
Subject: |
Re: problem with trailing comment in repl |
Date: |
Sun, 13 Feb 2011 10:22:24 -0500 |
Hello all,
I was thinking about how this might be solved. I can see two ways of doing it:
- The nicer way: add a new read function (or a keyword argument to the
current read function) that can tell it to stop without returning
anything if it hits a newline and there's no more input ready on its
port. You'd probably have to have it return a special "no expression"
token, but you could make that with an uninterned symbol.
- The quicker way: if the language in use is scheme, change the
next-char function (repl.scm line 205) to know about comments, so that
if it saw a semicolon, it would snarf everything until the end of the
line.
Either way is language-specific, but I don't think that's really
avoidable since different languages have different comment syntaxes.
Either way could also lead to a situation where some languages (i.e.
Scheme) had the nice prompt-printing functionality and others didn't,
but again, I think that's to be expected if this has to be implemented
once per language.
What do you all think of these ideas?
Noah
On Sat, Feb 12, 2011 at 9:36 AM, Andy Wingo <address@hidden> wrote:
> On Sat 12 Feb 2011 14:21, "Jose A. Ortega Ruiz" <address@hidden> writes:
>
>> I'm not sure i understand this reasoning, because when there are two (or
>> more) complete sexps in a line they're accepted, and a new prompt
>> appears;
>
> Of course.
>
> 1. Guile: No input available, print prompt:
> guile>
>
> 2. User: one line of input:
> (exp-1) (exp-2)
>
> 3. Guile: read one sexp
>
> 4. Guile: flush whitespace; input state is:
> (exp-2)
>
> 5. Guile: Input is ready, so don't print prompt, just read
>
> 6. Guile: Flush whitespace, no input available, so print prompt:
> guile
>
>> i was expecting a comment to be equivalent to whitespace.
>
> We could add some hacks in that regard, but it wouldn't work for
> ecmascript... If there is input, Guile calls `read', not some
> hypothetical `read-syntax' that could return a comment, and `read'
> doesn't return until it has read an entire expression.
>
>> However, i think there's a problem with metacommands at the
>> "non-prompt":
>>
>> scheme@(guile-user)> ;; foo
>> ,error
>> While compiling expression:
>> Syntax error:
>
> Meta-commands have to be the first thing on the prompt. It's a special
> case to look for the comma character; once we've seen non-whitespace --
> ";" in this case -- we're in the scheme reader, not the repl reader.
>
> Regards,
>
> Andy
> --
> http://wingolog.org/
>
>
- problem with trailing comment in repl, Jose A. Ortega Ruiz, 2011/02/11
- Re: problem with trailing comment in repl, Andy Wingo, 2011/02/12
- Re: problem with trailing comment in repl, Jose A. Ortega Ruiz, 2011/02/12
- Re: problem with trailing comment in repl, Andy Wingo, 2011/02/12
- Re: problem with trailing comment in repl,
Noah Lavine <=
- Re: problem with trailing comment in repl, Andy Wingo, 2011/02/13
- Re: problem with trailing comment in repl, Noah Lavine, 2011/02/13
- Re: problem with trailing comment in repl, Ludovic Courtès, 2011/02/14
- Re: problem with trailing comment in repl, Noah Lavine, 2011/02/14