Comments (13)
Oh, I got it.
y-or-n-p
and yes-or-no-p
do not consume newline character after reading the answer.
Can you replace the CormanLisp.img
file in the installation directory with the attached one and test if it works as it should?
from cormanlisp.
@LandKingdom Use triple backticks.
Can confirm this issue - read-line
is not being interpreted correctly while in the IDE.
It also does not work correctly in the Linux prompt via Wine - it seems to automatically swallow the ending newline and return immediately what is after the (read-line)
call.
?(read-line)
""
NIL
?(read-line)423
"423"
NIL
from cormanlisp.
Corman's "Lisp Worksheet" is not exactly a REPL, it is more like the *scaratch*
buffer in Emacs.
@LandKingdom, use Shift+Enter to supply input for your prompt while in the IDE. Does it work as expected?
@phoe, It is an interesting find, it does not work properly in Windows prompt either.
from cormanlisp.
@arbv Shift+Enter for read-line
does not work properly in the IDE.
Typing (read-line)
Shift+Enter 123
Shift+Enter leads to:
from cormanlisp.
@arbv I'm launching clconsole from the integrated Powershell terminal in VSCode. (I'm not using your bundled IDE)
from cormanlisp.
This also happens when running the REPL program directly (double-click from explorer) so it's not a PowerShell/Cmd.exe specific issue
from cormanlisp.
@phoe
From within IDE read-line
works as expected if you select an empty line after the expression.
Lisp<->IDE interaction model has its flaws, but fixing this requires a lot of refactoring. It won't happen this round. At least current model is predictable to the some extent.
from cormanlisp.
from cormanlisp.
I have updated the 3.1 release to include the fix for this issue.
from cormanlisp.
With the following code (same as earlier but added a looping functionality over promp-for-data) the error persists:
(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
(defun prompt-for-data ()
(prompt-read "String 1")
(prompt-read "String 2")
(or (parse-integer (prompt-read "Number 1") :junk-allowed t) 0)
(y-or-n-p "Bool 1"))
(defun add-records ()
(loop (prompt-for-data)
(if (not (y-or-n-p "Another? "))
(return))))
REPL:
?(add-records)
String 1: A
String 2: B
Number 1: 0
Bool 1(Y/N)
Y
Another? (Y/N)
Y
String 1: String 2: C
Number 1: 1
Bool 1(Y/N)
Y
Another? (Y/N)
N
NIL
?
EDIT: Fixed formatting
from cormanlisp.
Works as it should!
from cormanlisp.
@LandKingdom, thanks for helping to investigate the bug.
I have updated the installer once again.
I am closing the issue.
from cormanlisp.
When ran from clconsole.exe -execute foo.lisp
, with a last line of (prompt-for-data)
appended, this is produced:
PS C:\Users\bb010g> clconsole.exe -execute 'sample-1.lisp'
;; Corman Lisp 3.1 (Patch level 2)
;; Copyright (c) Corman Technologies Inc. See LICENSE.txt for license information.
;; User: bb010g.
Type :quit to exit.
?PROMPT-READ
?PROMPT-FOR-DATA
?String 1: String 2:
Whatever you input will be read as string 2, number 1, and bool 1.
Additionally, these programs freak Corman Lisp out:
Sample 2
(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
(prompt-read "1")
(prompt-read "2")
(prompt-read "3")
(prompt-read "4")
(prompt-read "5")
PS C:\Users\bb010g> clconsole.exe -execute 'sample-2.lisp'
;; Corman Lisp 3.1 (Patch level 2)
;; Copyright (c) Corman Technologies Inc. See LICENSE.txt for license information.
;; User: bb010g.
Type :quit to exit.
?PROMPT-READ
?1: "(prompt-read \"2\")"
NIL
?3: "(prompt-read \"4\")"
NIL
?5: "(win:ExitProcess 0)"
NIL
?:quit
The :quit
is entered manually to exit the process.
Sample 3
(y-or-n-p "1")
(y-or-n-p "2")
PS C:\Users\bb010g> clconsole.exe -execute 'sample-3.lisp'
;; Corman Lisp 3.1 (Patch level 2)
;; Copyright (c) Corman Technologies Inc. See LICENSE.txt for license information.
;; User: bb010g.
Type :quit to exit.
?
1(Y/N)
(Y/N)
T
?;;; An error of type UNBOUND-VARIABLE was detected in function #< COMPILED-FUNCTION: #x3662E80 >:
;;; Error: The variable -OR-N-P is unbound
;;; Entering Corman Lisp debug loop.
;;; Use :C followed by an option to exit. Type :HELP for help.
;;; Restart options:
;;; 1 Abort to top level.
:c 1
;;; Returning to top level loop.
?:quit
Manual :c 1
and :quit
again.
Sample 4
(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
(prompt-read "1a")
(y-or-n-p "1b")
(y-or-n-p "1c")
(prompt-read "2a")
(y-or-n-p "2b")
(y-or-n-p "2c")
PS C:\Users\bb010g> clconsole.exe -execute 'sample-4.lisp'
;; Corman Lisp 3.1 (Patch level 2)
;; Copyright (c) Corman Technologies Inc. See LICENSE.txt for license information.
;; User: brayden.
Type :quit to exit.
?PROMPT-READ
?1a: "(y-or-n-p \"1b\")"
NIL
?
1c(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
T
?;;; An error of type UNBOUND-VARIABLE was detected in function #< COMPILED-FUNCTION: #x35894E8 >:
;;; Error: The variable -OR-N-P is unbound
;;; Entering Corman Lisp debug loop.
;;; Use :C followed by an option to exit. Type :HELP for help.
;;; Restart options:
;;; 1 Abort to top level.
:quit
Manual :quit
.
Sample 5
(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
(prompt-read "1a")
(y-or-n-p "1b")
(y-or-n-p "1c")
(read-line *query-io*)
(prompt-read "2a")
(y-or-n-p "2b")
(y-or-n-p "2c")
(read-line *query-io*)
PS C:\Users\bb010g> clconsole.exe -execute 'sample-5.lisp'
;; Corman Lisp 3.1 (Patch level 2)
;; Copyright (c) Corman Technologies Inc. See LICENSE.txt for license information.
;; User: bb010g.
Type :quit to exit.
?PROMPT-READ
?1a: "(y-or-n-p \"1b\")"
NIL
?
1c(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
NIL
?;;; An error of type UNBOUND-VARIABLE was detected in function #< COMPILED-FUNCTION: #x32694D8 >:
;;; Error: The variable E is unbound
;;; Entering Corman Lisp debug loop.
;;; Use :C followed by an option to exit. Type :HELP for help.
;;; Restart options:
;;; 1 Abort to top level.
:c 1
;;; Returning to top level loop.
?:quit
Manual :c 1
and :quit
.
Sample 6
(progn (y-or-n-p "1a"))
PS C:\Users\bb010g> clconsole.exe -execute 'sample-6.lisp'
;; Corman Lisp 3.1 (Patch level 2)
;; Copyright (c) Corman Technologies Inc. See LICENSE.txt for license information.
;; User: bb010g.
Type :quit to exit.
?
1a(Y/N)
(Y/N)
(Y/N)
(Y/N)
NIL
?:EXITPROCESS
?0
?;;; An error of type UNBOUND-VARIABLE was detected in function #< COMPILED-FUNCTION: #x2C9D6B8 >:
;;; Error: The variable COMMON-LISP::|)| is unbound
;;; Entering Corman Lisp debug loop.
;;; Use :C followed by an option to exit. Type :HELP for help.
;;; Restart options:
;;; 1 Abort to top level.
:quit
Manual :quit
.
This one has an especially pretty error:
Sample 7
(y-or-n-p "1a")
(ccl:lisp-shutdown "")
PS C:\Users\bb010g> clconsole.exe -execute 'sample-7.lisp'
;; Corman Lisp 3.1 (Patch level 2)
;; Copyright (c) Corman Technologies Inc. See LICENSE.txt for license information.
;; User: bb010g.
Type :quit to exit.
?
1a(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
(Y/N)
NIL
?;;; An error of type UNBOUND-VARIABLE was detected in function #< COMPILED-FUNCTION: #x3312DE0 >:
;;; Error: The variable COMMON-LISP::|)| is unbound
;;; Entering Corman Lisp debug loop.
;;; Use :C followed by an option to exit. Type :HELP for help.
;;; Restart options:
;;; 1 Abort to top level.
:c 1
;;; Returning to top level loop.
?:quit
from cormanlisp.
Related Issues (20)
- *print-case* :capitalize does not capitalize printed values HOT 3
- The Format function's F directive's k parameter fails when preceded only by a tilde and 2 commas HOT 2
- The Format function's $ directive only displays one 0 after the decimal when default is two HOT 3
- Do not change lineendings when editing files using Corman Lisp IDE
- Consider static linking of Visual C++ runtime to the executables HOT 24
- atan2 incorrect for some inputs HOT 3
- Using keyword symbols as slot-descriptors in DEFSTRUCT
- Error when trying to create STANDARD-METHOD instances. HOT 2
- Missing file clos-tests.lisp HOT 4
- DLL compiled in "debug"? HOT 5
- sampledll causes an error when client.exe exits HOT 4
- Quicklisp HOT 4
- Implement conventional command line switches (-eval, -norc, etc) HOT 1
- load-image fails: push-module-directory undefined HOT 1
- retarget corman common lisp to GCC (GNU compiler collection) HOT 1
- Corman Lisp running on M1-based Mac (via Windows for ARM) HOT 4
- Is there a Windows binary I can download? I don't need the source code HOT 2
- Can we interface with C#? HOT 1
- Is this project still being worked on? HOT 2
- Cannot start; a window flickers then disappears
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cormanlisp.