badkins
2022-2-1 15:46:45

TIL about <https://docs.racket-lang.org/reference/fasl.html|Fast-Load Serialization> - thanks @massung :)


cperivol
2022-2-1 16:19:57

is there a function that does the same as clojure’s slurp https://clojuredocs.org/clojure.core/slurp


cperivol
2022-2-1 16:20:00

?


sorawee
2022-2-1 16:21:23

file-&gt;string is the closest I can think of


sorawee
2022-2-1 16:22:53

More generally, there’s port-&gt;string which consumes a port as an argument


sorawee
2022-2-1 16:23:45

And you can provide a file port, or a HTTP port


cperivol
2022-2-1 16:52:05

yes port-&gt;string is the one, thanks!


massung
2022-2-1 17:12:10

Is there a way for me to make a hash table w/ an initial size (ie, # of buckets/slots)?


samth
2022-2-1 17:18:58

No, there isn’t. (Note that make-hash creates an empty hash and incrementally fills it.)


samth
2022-2-1 17:21:33

The underlying Chez procedures support a capacity argument, so adding the feature should be relatively straightforward.


cperivol
2022-2-1 18:21:45

is there a way to require non-provided symbols from a file?


soegaard2
2022-2-1 18:23:58

require/expose


cperivol
2022-2-1 18:35:22

Is there a standard multiplex port like such that (fprintf (mux-ports p1 p2) "abc") will send "abc" to both p1 and p2?


cperivol
2022-2-1 18:35:40

“standard” as in “one that I don’t have to install or implement”


soegaard2
2022-2-1 18:36:54

combine-output


cperivol
2022-2-1 18:42:58

Thanks!


massung
2022-2-1 18:53:11

in my case, i just know the hash gets large, and would like to reduce the resize/copying that takes place


cperivol
2022-2-1 19:52:31

is there any difference between (fprintf p "xyz ~a abc\r\n" "/") and (fprintf p (format "xyz ~a abc\r\n" "/"))?


cperivol
2022-2-1 19:53:49

The context is that p is an http port and the former prompts a slightly different response from the server.


samth
2022-2-1 19:55:56

Those should be the same (although more generally the second one can do format string substitution twice).


soegaard2
2022-2-1 19:56:27

Yep. Same output.

#lang racket

(define p1 (open-output-string)) (fprintf p1 "xyz ~a abc\r\n" "/") (get-output-string p1)

(define p2 (open-output-string)) (fprintf p2 (format "xyz ~a abc\r\n" "/")) (get-output-string p2)


soegaard2
2022-2-1 19:56:39

“xyz / abc\r\n” “xyz / abc\r\n”


cperivol
2022-2-1 20:01:32

Ok. This is what the thread we were talking about yesterday boils down to ( https://racket.slack.com/archives/C06V96CKX/p1643651087419999


cperivol
2022-2-1 20:03:43

Changing a single line fixes it: (fprintf p "~a ~a HTTP/~a\r\n" .... ) to (fprintf p (format "~a ~a HTTP/~a\r\n" .... ))


cperivol
2022-2-1 20:04:20

not even to all lines of the request header. Just this line of the header determines if the response contains a header or if it’s just the body


cperivol
2022-2-1 20:04:33

and I can’t reproduce it on any other network


cperivol
2022-2-1 20:04:35

:disappointed:


soegaard2
2022-2-1 20:05:51

Which single line are we looking at?


greg
2022-2-1 20:06:22

In http-conn-send!?


cperivol
2022-2-1 20:07:05

yes


samth
2022-2-1 20:07:16

My guess is that it’s about how many bytes are sent at once. Probably the former writes each interpolated piece separately to the port, whereas the latter processes the entire string at once.


cperivol
2022-2-1 20:07:23

http-client.rkt:162


samth
2022-2-1 20:07:47

And something on your network is doing things too eagerly, or something like that.


cperivol
2022-2-1 20:08:31

probably right @samth are there any relevant knobs I can turn?


samth
2022-2-1 20:09:11

You could test it by changing the line to use multiple calls to fprintf without the format and see if that breaks.


samth
2022-2-1 20:09:48

It’s also possible that there’s some buffer size configuration on something that you could change.


cperivol
2022-2-1 20:11:12

Exactly, breaking it into 3 printfs reproduces the problem


cperivol
2022-2-1 20:12:27

(fprintf to "GET ") (fprintif to "/") (fprintf to " HTTP/1.1\r\n")


cperivol
2022-2-1 20:12:39

does the bad thing


cperivol
2022-2-1 20:13:05

(fprintf to "GET / HTTP/1.1\r\n") does the good thing


samth
2022-2-1 20:13:31

I’m pretty sure that this indicates a bug somewhere in your computer/OS/network/firewall/etc.


cperivol
2022-2-1 20:14:01

makes sense


cperivol
2022-2-1 20:14:02

thanks!


ryanc
2022-2-1 21:27:43

BTW, you should either use (fprintf p "~a" (format ___)) or (write-string (format ___) p). That is, it’s almost always a bad idea to call fprintf etc with a computed format string, since it might happen to contain formatting directives.


joseph.denman
2022-2-2 01:21:12

@joseph.denman has joined the channel