Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable char flushing at REPL end of lines #693

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jpellegrini
Copy link
Contributor

Hi @egallesio !
I'm not sure my implementation is ok, but as far as I have tested, it seems good...

This was inspired by a recent change in Gambit.

When a line is intered int the REPL, STklos will flush the characters in the list contained in the parameter obejct repl-flushed-characters. The default value is (#\space #\tab). Newlines and end-of-file are always flushed.

 stklos> (read-char)      <= no character after the closing parenthesis
 4                        <= user input
 #\4                      <= return value
 stklos> (read-char)      <= a space after the closing parenthesis
 4                        <= user input
 #\4                      <= return value
 stklos> (read-char)3     <= '3' after closing parenthesis
 #\3                      <= return value
 stklos> (read-char) 3    <= space and '3' after closing parenthesis
 #\3                      <= return value
 stklos> (read-char)35    <= '35' after closing parenthesis
 #\3                      <= return value
 5                        <= next return value

stklos>  (repl-flushed-characters '())
 stklos> (read-char)      <= no character after the closing parenthesis
 4                        <= user input
 #\4                      <= return value
 stklos> (read-char)      <= a space after the closing parenthesis
 #\space                  <= return value (the space was not skipped)
 stklos> (read-char)3     <= '3' after closing parenthesis
 #\3                      <= return value
 stklos> (read-char) 3    <= space and '3' after closing parenthesis
 #\space                  <= return value (the space was not skipped)
 #\3                      <= next return value
 stklos> (read-char)35    <= '35' after closing parenthesis
 #\3                      <= return value
 5                        <= next return value

When a line is intered int the REPL, STklos will flush the characters
in the list contained in the parameter obejct `repl-flushed-characters`.
The default value is `(#\space #\tab)`. Newlines and end-of-file are
always flushed.

```
 stklos> (read-char)      <= no character after the closing parenthesis
 4                        <= user input
 #\4                      <= return value
 stklos> (read-char)      <= a space after the closing parenthesis
 4                        <= user input
 #\4                      <= return value
 stklos> (read-char)3     <= '3' after closing parenthesis
 #\3                      <= return value
 stklos> (read-char) 3    <= space and '3' after closing parenthesis
 #\3                      <= return value
 stklos> (read-char)35    <= '35' after closing parenthesis
 #\3                      <= return value
 5                        <= next return value

 (repl-flushed-characters '())
 stklos> (read-char)      <= no character after the closing parenthesis
 4                        <= user input
 #\4                      <= return value
 stklos> (read-char)      <= a space after the closing parenthesis
 #\space                  <= return value (the space was not skipped)
 stklos> (read-char)3     <= '3' after closing parenthesis
 #\3                      <= return value
 stklos> (read-char) 3    <= space and '3' after closing parenthesis
 #\space                  <= return value (the space was not skipped)
 #\3                      <= next return value
 stklos> (read-char)35    <= '35' after closing parenthesis
 #\3                      <= return value
 5                        <= next return value
```
@jpellegrini
Copy link
Contributor Author

This is interesting so we can enter characters to read-char on the REPL (currently STklos won't let us type, it will read the newline and return it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant