freenode/#lisp - IRC Chatlog
Search
9:15:00
fiddlerwoaroof
Any way to copy a hash table exactly, including implementation-specific extensions
9:17:06
verisimilitude
If this isn't sufficient, then there's no standard way to do what you want, then, I don't believe.
9:18:06
fiddlerwoaroof
oops, copying is the wrong word, I want an empty hash-table that's exactly like the given hash-table
9:19:50
verisimilitude
Well, there's no COPY-HASHTABLE, so it doesn't seem there's a standard way to get this either, fiddlerwoaroof.
9:20:50
no-defun-allowed
(make-hash-table :test (hash-table-test foo) :rehash-size ... :size ...) is probably the best way to copy the metadata on the table.
10:02:44
pjb
(apropos-list "COPY-HASH")) #| --> (com.informatimago.common-lisp.lisp-reader.reader::copy-hash-table com.informatimago.common-lisp.cesarum.utility:copy-hash-table alexandria.0.dev:copy-hash-table) |#
10:04:02
pjb
verisimilitude: I guess you could reclaim from vendors providing non-standard meta-data for hash-table, to provide a extensions:copy-hash-table function…
10:17:57
no-defun-allowed
I'd like to try to create a frame which (to the user) magically contains an infinite set of gadgets, which are loaded as the user scrolls down.
10:23:04
no-defun-allowed
Actually, I'll pick this up tommorow, this might be too complex given it's almost bedtime.
11:50:20
imjacobclark
Hello - I am delving into the world of socket programming with sbcl and Lisp, I have a working TCP server (woop) which can receive data and send data back. My dad is received as an octet stream and thrown into an array with an element type of unsigned-byte
11:50:54
imjacobclark
how could i go about this? LOC relevant: https://github.com/imjacobclark/cl-servers/blob/master/simple-tcp-server.lisp#L16
11:53:58
pjb
(make-array 2042 :element-type '(unsigned-byte 8) :initial-element 0 :adjustable t :fill-pointer 0)
11:54:57
imjacobclark
pjb: so would this rely on "(sb-bsd-sockets:socket-receive accepted-socket *receive-buffer* nil)" being able to do adjust-array/vector-push-extend ?
11:55:19
pjb
You would have to adjust it before receiving, to free some space where to receive the data.
11:56:28
imjacobclark
interesting, i guess I would never know the size of the data before I receive, and i clear the buffer anyway before i receive new data
11:57:35
imjacobclark
as afaik - i cant peek at the size of the receiving buffer until i actually receive it, which is what sb-bsd-sockets:socket-receive does
11:59:11
pjb
Content-Length: actually https://www.oreilly.com/library/view/http-the-definitive/1565925092/ch15s02.html
11:59:56
imjacobclark
doesn't socket-receive take the entire response though, how could i chunk it up so i can read the content-length header first?
12:00:26
imjacobclark
(as technically at that point the data has been received, regardless of your buffering)
12:01:14
nirved
imjacobclark: you could look at how it's done in other software, i.e. drakma - https://github.com/edicl/drakma/blob/master/request.lisp#L129
12:06:15
nirved
imjacobclark: for post data you could see at hunchentoot too - https://github.com/edicl/hunchentoot/blob/master/request.lisp#L150
12:50:41
Xach
imjacobclark: i've seen one client read a byte at a time until it gets the end-of-header marker.
12:51:24
imjacobclark
Xach: is this possible with sb-bsd-sockets? I know usocket returns 4 bytes at a time, but I think sb-bsd-sockets:socket-read wants to read the whole thing all at once
12:52:33
imjacobclark
how is that achieved? ive tried (sb-bsd-sockets:socket-receive accepted-socket "" 8) and then another (sb-bsd-sockets:socket-receive accepted-socket "" 8)
12:54:36
Xach
(sb-bsd-sockets:socket-receive socket buffer (length buffer)) is the thing to use, then look at the second value to see how much you got.
12:55:20
Xach
If you only want to read 1 byte, use a length of 1, but make sure the buffer is able to hold at least one thing.
12:55:39
imjacobclark
so, once i know the second value (e.g how much I got) what do I do next to continue reading?
12:58:02
Xach
you can get a long way with an api that does something like "call a function on each chunk you get up to matching this particular pattern" and "call a function on each chunk you get for a certain number of bytes". higher-level things can be build on top of that.
12:58:56
Xach
http generally goes: headers end with a pattern, body has a fixed size. or if it's chunked, it's headers up to a pattern, many repeated header pattern/sized chunks.
12:59:30
imjacobclark
so looking at this: https://gist.github.com/imjacobclark/cc68d5803ee96b80576a4c8b0e4a55ab
12:59:46
imjacobclark
https://gist.github.com/imjacobclark/cc68d5803ee96b80576a4c8b0e4a55ab#file-gistfile1-txt-L32-L33
13:03:30
imjacobclark
at the moment, using netcat - if i type "hi" and hit enter, it waits for a second input of "hi" and proceeds to print a single hi on the server
13:04:01
imjacobclark
really i guess what i want to achieve is the ability to pass an arbitrary long string across to the server which it can chunk up and read into a buffer
13:07:51
imjacobclark
I don't - it prompts for a second input, I type hi again and then it closes, writing back hi...
13:08:33
imjacobclark
it immediately returns "hi" (which I programmed the server to send back the string hi)
13:09:20
Xach
imjacobclark: so if the client socket sends three bytes, the first call returns, and puts that data in the buffer. then the next read will read whatever is available, again. then the server prints the buffer and returns.
13:09:36
Xach
if you send more than 16 bytes, both calls return immediately because there is data there.
13:10:00
imjacobclark
are you saying, its returning and closing the socket because im not handling that return
13:10:02
Xach
if the client socket is closed, the socket-read returns 0 length, which is the special value that means it's done in this case.
13:10:50
Xach
and the second return value tells you what you got, and a second return value of 0 is special.
13:11:17
imjacobclark
so when i send "hello world" over as 8 bit the server only prints "rld - why is it reading from the back?
13:11:40
Xach
imjacobclark: you are using one buffer without printing after the first call. the second read overwrites the first.
13:13:56
imjacobclark
I see what you mean by it returning now, its read less data than it expected to, so it waits for the next lot
13:14:10
imjacobclark
thats why i should wait for the EOL to know when ive really finished reading, right?
13:15:28
imjacobclark
i guess in this case - to be very simple, i'd just like to know when there is no more data left to read
13:15:29
Xach
you can't know in advance how much data you'll get so you have to piece it together if you want to read patterns
13:16:19
imjacobclark
i couldn't see that in the sbcl user man, how did you find that out? http://www.sbcl.org/manual/#Sockets-Overview
13:18:14
Xach
SBCL's sb-bsd-sockets is a relatively thin layer over it - in a pinch you can make your own thin layer.
13:24:06
Xach
Not that you should necessarily roll your own when sb-bsd-sockets is generally good enough. I'm easily disgruntled with it, though, and know how to get to the low-level functionality i want.
13:45:14
akater
Fun fact: in ECL, (defclass q nil nil nil) creates a class. In SBCL, error is signalled.
13:48:28
akater
(The error message mentions an initarg while no initarg was actually provided in the form.)
13:48:31
pjb
Something like: Class option nil is not one of (:primary-p :documentation :direct-default-initargs :direct-slots :direct-superclasses :name) ? How is that not very helpful?
13:49:05
akater
I get Invalid initialization argument: NIL in call for class #<STANDARD-CLASS COMMON-LISP:STANDARD-CLASS>.
13:51:30
akater
Yes. The initial form did not contain anything resembling an initialization argument. Also: I only checked in Maxima's ECL on my Android so it might be dated.
14:09:56
imjacobclark
Xach: So I changed my buffer length to 1 and used (print (nth-value 1 (sb-bsd-sockets:socket-receive accepted-socket *receive-buffer* (length *receive-buffer*)))) to view the second return of of the socket-receive function
14:10:22
imjacobclark
underneath the first (print (nth-value 1 (sb-bsd-sockets:socket-receive accepted-socket *receive-buffer* (length *receive-buffer*)))) I have another (print (nth-value 1 (sb-bsd-sockets:socket-receive accepted-socket *receive-buffer* (length *receive-buffer*))))
14:10:36
imjacobclark
the second nth-value prints nothing until the next socket request, but it prints 1, not 0 like you suggegst
14:20:58
Xach
imjacobclark: i suggest it will return 0 when there is no data left to read and the remote end has shut down.
14:25:12
imjacobclark
So I expect that, when running this code: https://gist.github.com/imjacobclark/89723165137efc5e506a4095fcaee7e9 - then doing "nc localhost 8080" - it will prompt for data, I will type "h" [enter] - the server will at first print the length of the sequence "h" [enter] from the socket-recieve and the second socket-recieve will print 0
14:26:44
imjacobclark
once ive done "h" [enter] it removes the ability to input, and on the server I have the line (sb-bsd-sockets:socket-send accepted-socket *response* *response-length*) - so it immediately then says "hi"
14:32:25
Xach
ctrl-d mainly means "push what data is pending" - something newline also does, but includes a newline
14:32:26
imjacobclark
so thats cool - i guess theres nothing wrong with the code, nc is sending [enter] litterally
14:34:22
imjacobclark
Last thing then, so when I have a (print buffer) directly after my socket-receive - it doesn't immediately print, it prints on the next lot of input from the client, its as if socket-receive is causing the loop to short circuit when its done reading - is that expected?
15:32:59
imjacobclark
Xach: Thanks for your help again, I'm now able to read chars sent in, at the min it overwrites the buffer each time, i just need to work out how to adjust the buffer size :) https://github.com/imjacobclark/cl-servers/blob/master/simple-tcp-server.lisp#L20-L26
17:09:44
kenu
Trying to change session-cookie-name in hunchentoot, but what does it exactly mean to specilize generic function and how one do that?
17:17:52
_death
if you have your own acceptor (sub)class, then it's a matter of (defmethod hunchentoot:session-cookie-name ((acceptor my-acceptor)) <code here>)
18:04:09
makomo
can anyone tell me how much was ELS registration the previous few years (preferably for students)?
18:04:31
makomo
i think i heard someone say that it was rather low/symbolic, especially for students
18:05:48
makomo
are such prices the norm? was it previously lower but now that it's colocated with <Programming> it's higher?
18:09:01
MichaelRaskin
In the middle of the page of year 2019 I see «Because the student fee is higher than our normal rate, we will also implement a student refund program when the conference is over, as we did two years ago.»
18:13:51
MichaelRaskin
makomo: It is possible that there is something not completely clear about the exact interaction with the maing organising committee.
18:14:56
jackdaniel
before programming the cost was (if I recall correctly) 40 euro for students and 80 euro for everyone else (early birds)
18:17:00
MichaelRaskin
Anyway, in 2017 I see an announcement of a not-too-complicated procedure with a 50€ refund for students registered for workshop days of Programming and precommitting to attend both days of ELS and signing some paperwork in the ELS room on both days.
18:18:12
MichaelRaskin
Yes, in 2017 (which was probably the first year of once-in-two-years Programming)
19:04:46
Xach
It makes me sad because this is essentially the only Common Lisp conference in the world right now.
19:21:44
margaritamike
Is it harder to do refactoring in Common Lisp than other languages like Java/Haskell?