freenode/#lisp - IRC Chatlog
Search
19:38:39
imjacobclark
Could somebody point me in the right direction onto how I can send data back from sb-bsd-sockets:socket-make-stream (e.g a string of html)? I have this code but when I try to use socket-send I get a socket closed error - https://github.com/imjacobclark/cl-server/blob/master/server.lisp#L19-L20
19:48:51
imjacobclark
yes, id like to look at the http header, essentially - then eventually do a cond and return a different response for different requests
19:49:00
imjacobclark
for now though, i guess just printing the headers and returning a single response would beok
19:49:59
imjacobclark
So, the code in the gist right now allows me to accept a connection (via a browser) and it prints " ET / HTTP/1.1
19:51:05
imjacobclark
there is a very high chance im misunderstanding or missing something - ive strung what i have together by searching github - a lot for examples and some sbcl docs
19:53:26
imjacobclark
it does indeed return the http headers, thats fine - but i want to understand how to send a response back to the client
19:57:25
imjacobclark
(loop (with-open-stream (stream (stream-connection socket)) (print (read-line stream))))
19:58:37
imjacobclark
okay, so " (loop (with-open-stream (stream (stream-connection socket)) (write-string "test" stream) (finish-output stream)))"
19:59:38
aeth
The alternative style is to rebind *standard-output* to your destination stream. I prefer explicitly passing the stream, though.
20:01:05
imjacobclark
[clarkj84:~/Desktop/cl-server]$ curl localhost:8080 (master✱) curl: (52) Empty reply from server
20:01:27
imjacobclark
The new code I added being here: https://github.com/imjacobclark/cl-server/blob/master/server.lisp#L28-L37
20:04:53
imjacobclark
yeah, nc connects to the server and I get "Connection to localhost port 8080 [udp/http-alt] succeeded!" - but no response - im expecting it to return "test"
20:07:06
imjacobclark
i guess all i need to do next is format that response to something curl or chrome can understand
20:51:17
imjacobclark
i have another question, about streams - im reading a socket stream line by line, it works fine, but the while in my loop never seems to trigger, hanging the entire program - what could that be? https://github.com/imjacobclark/cl-server/blob/master/server.lisp#L31
20:56:54
no-defun-allowed
Implementations could only allow for a fairly small apply list. I forgot the number though, maybe it was around 50.
21:00:15
no-defun-allowed
That's true, the &rest list is passed as plain conses so it could optimise for that.
21:00:51
Duns_Scrotus
i mean if its just passing a literal list how would it even limit the number of arguments
21:04:26
no-defun-allowed
A very naive intepreter would take the argument list, eval every item in the list, then find the function, destructure the list and evaluate the lambda body with the xestructured values.
21:05:27
no-defun-allowed
*destructured. This is truly the worst case, and this could have been an issue in the 80s with very expensive memory.
21:53:24
no-defun-allowed
They are also moving to chez scheme, which is faster than their C backend iirc.
22:41:19
aeth
LdBeth: Ruby's the slowest here, and Racket is comparable to Julia, a bit slower. SBCL is, of course, faster, but its relative position seems to have been slipping. It might slip off of the bottom graph soon, like Haskell has. https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fast.html
22:41:50
aeth
Oh, sorry, it has two Ruby's now and one of them isn't the slowest, but is still pretty slow.
22:42:17
aeth
Duns_Scrotus: The benchmarks game is awful for specific numbers, but it does imo help suggest "performance classes" of languages
22:43:10
aeth
Intuitively, Ruby's main implementation is going to be slower than SBCL (or even Racket) just based on how they're written.
22:51:26
Duns_Scrotus
his racket brainfuck interpreter grows the array by allocating a new array exactly one bigger
22:53:08
aeth
Brainfuck itself isn't particularly designed to be efficient. It's designed to be easy to implement. And in some languages the easy route is going to be slower than others.
22:53:47
Duns_Scrotus
but for mandel.b, which presumably grows the tape a lot, it is indeed very slow
22:54:18
aeth
I mean, clearly the solution is to implement it in the hardware with a Brainfuck Machine.
22:59:17
Duns_Scrotus
https://github.com/kostya/benchmarks/blob/master/brainfuck2/bf.rkt why did he write it like this
23:37:55
emaczen
I'm trying to cffi:foreign-funcall a function that was defined as "static inline", but am always told that this function is undefined. What are easy ways around this?
23:38:33
emaczen
obviously I could just copy and paste the function, remove the static inline, compile and then load this foreign library
23:49:59
no-defun-allowed
by the sounds of it, the function isn't in the binary, just inlined wherever
23:58:34
Bike
a function declared static has file scope, so with inline it probably won't exist in the binary.