rep.lsp
#!/usr/bin/newlisp
;; file: rep.lsp
;; purpose: read-eval-print loop by Tk text widget
;; tcl script in rep.tcl provides interactive text window
(tk "source rep.tcl")
;; escape double quotes the electrical way
;; avoids quoting hell by hand
(define (escape str)
(join
(map
(lambda (c)
(if (member c '("\"" "\\"))
(append "\\" c)
c))
(explode str))))
;; print-form of typed Lisp data
(define (typedString el)
(cond ((string? el) (append "\"" (escape el) "\""))
((list? el) (append {(} (join (map typedString el) { }) {)}))
((array? el) (typedString (array-list el)))
(true (escape (string el)))))
;; the command Tk will send on <Return>
;; "println" is a Tcl script to write in Text window
(define (respond expr)
(let (a (typedString expr))
(tk (append "println " (typedString a)))))
;; eof
6.1.2023
<< | Heimatseite | Verzeichnis | Stichworte | Autor | >>