Replaces tail-call with loop.
This commit is contained in:
parent
bff30b9443
commit
006fa693d3
2 changed files with 17 additions and 21 deletions
11
loop.lisp
11
loop.lisp
|
@ -1335,11 +1335,12 @@
|
|||
:handler #'cli/main-with-handlers))
|
||||
|
||||
(defun main-loop ()
|
||||
(let* ((bs (nntp-read-line))
|
||||
(ln (bytes->string (ucs-2->ascii bs))))
|
||||
(let ((r (send-response! (dispatch-line ln))))
|
||||
(when (not (response-quit? r))
|
||||
(main-loop)))))
|
||||
(loop
|
||||
(let* ((bs (nntp-read-line))
|
||||
(ln (bytes->string (ucs-2->ascii bs))))
|
||||
(let ((r (send-response! (dispatch-line ln))))
|
||||
(when (response-quit? r)
|
||||
(return))))))
|
||||
|
||||
(defun request-quit? (r) (and r (string= 'quit (request-verb r))))
|
||||
(defun response-quit? (r) (and r (request-quit? (response-request r))))
|
||||
|
|
27
loop.nw
27
loop.nw
|
@ -397,12 +397,7 @@ LOOP> quit
|
|||
What happens is that [[read]] consumes just the symbol \verb|quit|, so
|
||||
there remains a \verb|\n| or \verb|\r\n| in the [[*standard-input*]],
|
||||
which we need to wipe out, or [[nntp-read-line]] will consume an empty
|
||||
line, which is what causes that 400 response\footnote{Months ago I
|
||||
pondered whether I should ignore an empty command or whether I should
|
||||
write back an empty response such as this one---I beg your pardon? I
|
||||
decided to not ignore. By not ignoring, [[read]] now called my
|
||||
attention to the fact that a trailing \verb|\r\n| is left, which seems
|
||||
good to know.}.
|
||||
line, which is what causes that 400 response.
|
||||
|
||||
<<Loop's REPL>>=
|
||||
(defun repl (r)
|
||||
|
@ -636,11 +631,12 @@ itself---so we can cascade actions based on a user's request.
|
|||
|
||||
<<Main loop>>=
|
||||
(defun main-loop ()
|
||||
(let* ((bs (nntp-read-line))
|
||||
(ln (bytes->string (ucs-2->ascii bs))))
|
||||
(let ((r (send-response! (dispatch-line ln))))
|
||||
(when (not (response-quit? r))
|
||||
(main-loop)))))
|
||||
(loop
|
||||
(let* ((bs (nntp-read-line))
|
||||
(ln (bytes->string (ucs-2->ascii bs))))
|
||||
(let ((r (send-response! (dispatch-line ln))))
|
||||
(when (response-quit? r)
|
||||
(return))))))
|
||||
|
||||
(defun request-quit? (r) (and r (string= 'quit (request-verb r))))
|
||||
(defun response-quit? (r) (and r (request-quit? (response-request r))))
|
||||
|
@ -2030,11 +2026,10 @@ all or it has been discussed with the community beforehand.
|
|||
|
||||
\subsection{{\tt REPL}}
|
||||
|
||||
Mean for hackers, \lp\ is totally {\em hackable}. After
|
||||
authentication, users can say {\tt repl} to have complete control over
|
||||
their \lxxp\ process. XXX: we should implement an option
|
||||
[[--disable-repl]] so that REPL hacking is turned off. (This would
|
||||
mean your users are not true hackers.)
|
||||
\lp\ is totally {\em hackable}. Users can say {\tt repl} to have
|
||||
complete control over their \lxxp\ process. XXX: we should implement
|
||||
an option [[--disable-repl]] so that REPL hacking is turned off.
|
||||
(This would mean your users are not true hackers.)
|
||||
|
||||
<<Command repl>>=
|
||||
(defun cmd-repl (r)
|
||||
|
|
Loading…
Reference in a new issue