Giter Club home page Giter Club logo

Comments (13)

arbv avatar arbv commented on August 23, 2024 1

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?

CormanLisp.zip

from cormanlisp.

phoe avatar phoe commented on August 23, 2024

@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.

arbv avatar arbv commented on August 23, 2024

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.

phoe avatar phoe commented on August 23, 2024

@arbv Shift+Enter for read-line does not work properly in the IDE.

Typing (read-line) Shift+Enter 123 Shift+Enter leads to:

zrzut ekranu z 2019-01-01 14-01-32

from cormanlisp.

Karrq avatar Karrq commented on August 23, 2024

@arbv I'm launching clconsole from the integrated Powershell terminal in VSCode. (I'm not using your bundled IDE)

from cormanlisp.

Zulu-Inuoe avatar Zulu-Inuoe commented on August 23, 2024

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.

arbv avatar arbv commented on August 23, 2024

@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.

1

from cormanlisp.

arbv avatar arbv commented on August 23, 2024

Fixed.

from cormanlisp.

arbv avatar arbv commented on August 23, 2024

I have updated the 3.1 release to include the fix for this issue.

from cormanlisp.

Karrq avatar Karrq commented on August 23, 2024

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.

Karrq avatar Karrq commented on August 23, 2024

Works as it should!

from cormanlisp.

arbv avatar arbv commented on August 23, 2024

@LandKingdom, thanks for helping to investigate the bug.

I have updated the installer once again.

I am closing the issue.

from cormanlisp.

bb010g avatar bb010g commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.