From fd4aa4fae67ae908338f5febfd4f5fe6f404a1fa Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sun, 28 Mar 2021 22:18:10 -0400 Subject: [PATCH] Issue #453 - Proper handing of EOF at the REPL Finally handle EOF correctly and do not exit REPL if an expression evaluates to the EOF object. However, allow CTRL-d to exit the REPL. --- CHANGELOG.md | 1 + scheme/repl.sld | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21fcec2e..3f69e477 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Features Bug Fixes - Arthur Maciel replaced high resolution code in the runtime to use `clock_gettime` instead of `gettimeofday`. +- Fixed the REPL to no longer automatically exit if an expression evaluates to EOF. However, the REPL will exit as a special case if the EOF character is entered directly, for example via CTRL-D on Linux. ## 0.27 - March 5, 2021 diff --git a/scheme/repl.sld b/scheme/repl.sld index fb148ca4..eed07c94 100644 --- a/scheme/repl.sld +++ b/scheme/repl.sld @@ -47,11 +47,12 @@ (newline) (repl)) (display "cyclone> ") - (let ((c (eval (read)))) - (cond - ((not (eof-object? c)) - (write c) - (newline) - (repl)) - (else - (display "\n")))))))) + (let ((obj (read))) + (if (eof-object? obj) + (newline) ;; Quick way to exit REPL + (let ((c (eval obj))) + (if (eof-object? c) + (display "") + (write c)) + (newline) + (repl))))))))