Skip to content

Instantly share code, notes, and snippets.

@metaleap
Created June 15, 2024 11:43
Show Gist options
  • Save metaleap/1351fbbbce4b2bfc7aa3294f9e32161a to your computer and use it in GitHub Desktop.
Save metaleap/1351fbbbce4b2bfc7aa3294f9e32161a to your computer and use it in GitHub Desktop.
(import :std/error
:std/sugar
:std/io
(only-in :std/net/httpd/handler read-request-headers read-request-body)
./lib)
(export main)
(include "../manifest.ss")
(def +input-buffer-size+ (expt 2 13))
(def +output-buffer-size+ (expt 2 15))
(defstruct Transport ((reader : Reader) (writer : Writer)) final: #t)
(def (transport-stdio)
(make-Transport (Reader (make-raw-binary-input-port (current-input-port)))
(Writer (make-raw-binary-output-port (current-output-port)))))
(def (main . args)
(def transport (transport-stdio))
(using (transport :- Transport)
(def ibuf (open-buffered-reader transport.reader +input-buffer-size+))
(def obuf (open-buffered-writer transport.writer +output-buffer-size+))
(while #t
(def headers (read-request-headers ibuf))
; (def json (bytes->json (read-request-body ibuf headers)))
(displayln "NOOP")
)))
@metaleap
Copy link
Author

metaleap commented Jun 15, 2024

Error for line 25, namely (def headers (read-request-headers ibuf)):

... build in current directory
*** ERROR IN __with-lock -- 
*** ERROR IN "revrepl/main.ss"@25.7-25.48
--- Syntax Error at (expand _/revrepl/main): Bad syntax; illegal expression
... form:   (begin (def headers (read-request-headers ibuf)) (displayln "NOOP") (lp))
... detail: (%#define-values (headers) (read-request-headers ibuf)) at "revrepl/main.ss"@25.7-25.48
*** ERROR IN std/misc/process#run-process__% -- 
*** ERROR IN "misc/process.ss"@28.35-28.46 [ProcessError]: process exited with non-zero status
--- irritants: "/home/_/c/l/learn-scheme/03-reverse-repl/build.ss" 17920 (path: "/home/_/c/l/learn-scheme/03-reverse-repl/build.ss" arguments: ("compile") environment: #f directory: #f stdin-redirection: #t stdout-redirection: #f stderr-redirection: #f pseudo-terminal: #f show-console: #f) 
--- continuation backtrace:
[0] raise                                                                              
[1] std/misc/process#run-process__%                                                                                                                                            ((if (procedure? _%check-status260866%_) _%check-status260866%_ std/misc/proc...

If I change it into a let, it compiles fine — so the call expression is not faulty. Yet the plain old (def <name> <expr>) syntax is also not violated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment