gknauth
2021-5-12 13:41:29

On my Manjaro [Arch] GNU/Linux machine, I installed 8.1, overwriting the old 8.0. I used Unix-style install, default to /usr/bin, because apparently that’s what I did the last time. In the terminal, when I type racket the banner comes up right away, but the prompt takes 43 seconds to appear. If I type drracket I get this: $ drracket standard-module-name-resolver: collection not found for module path: (lib "drracket/drracket.rkt") collection: "drracket" in collection directories: /home/gknauth/.racket/8.1/collects /usr/share/racket/collects/


gknauth
2021-5-12 13:49:12

This time I used the .sh script from http://racket-lang.org\|racket-lang.org. Last time I must have used the GUI package manager from Manjaro. I’m going to try uninstalling from that first and then try re-installing.


gknauth
2021-5-12 13:52:56

I uninstalled from the Manjaro GUI, then since 8.1 wasn’t available yet on Manjaro/Arch, I re-ran the install script, installing to ~/Apps/racket–8.1, and everything’s fine now.


mflatt
2021-5-12 16:41:22

I think there are already some packages or tools for managing multiple Racket installations (e.g., multiple versions). Can someone remind me what they are?


mflatt
2021-5-12 16:41:38

Asking because I’ve accidentally ended up creating another one in the process of building a cross-compilation wrapper…


pocmatos
2021-5-12 16:44:13

interesting - i started created one as well called raclette but I think nobody uses it besides me. :slightly_smiling_face:


pocmatos
2021-5-12 16:44:34

i just use it to ease compilation of racket locally whenever i need one.


pocmatos
2021-5-12 16:44:44

Although to be honest I haven’t touched it in a while.


pocmatos
2021-5-12 16:44:59

samth
2021-5-12 16:47:09

samth
2021-5-12 16:47:21

Which is probably the one @mflatt was thinking of


pocmatos
2021-5-12 16:47:34

wow - lol , everyone has their own… didn’t know that one from @asumu


samth
2021-5-12 16:49:01

I think something like rustup + integration with that for the raco/racket binaries would be really nice to have


samth
2021-5-12 16:49:23

how does raclette work (great name btw)


pocmatos
2021-5-12 16:51:18

The idea is really that you can just say - compile me this version and add these packages. Although I didn’t really advertise it because it’s missing some essential bits for public consumption and has been useful mostly for me.


pocmatos
2021-5-12 16:51:36

So, it always at the moment compiles racket from source. Which some people might not want.


samth
2021-5-12 16:51:43

ah


pocmatos
2021-5-12 16:51:54

However, I can choose, compile with ubsan or lto, or O0, or march=native, etc.


pocmatos
2021-5-12 16:52:22

I think at some point @mflatt changed something in the build system that broke it and I haven’t had the time to fix it so… that’s antoher thing to do… :slightly_smiling_face:


pocmatos
2021-5-12 16:52:34

but I agree that having something like rustup would be great.


samth
2021-5-12 16:53:14

the scripts I use (originally by Eli Barzilay) are really good for switching between lots of different installations, but don’t do the installation for you at all


mflatt
2021-5-12 17:04:02

Thanks! I doubt that raco cross is going to be a replacement for what you use, but it will turn out to be a relatively simple way to get at a minimal Racket installation.


samth
2021-5-12 17:08:45

well we should think about how to integrate them, at some point


dsmith
2021-5-12 17:18:54

@dsmith has joined the channel


samth
2021-5-12 18:29:08

@popa.bogdanp I think the local_catalogs feature is duplicating things: https://github.com/racket/typed-racket/pull/1095/checks?check_run_id=2569198853#step:3:45


samth
2021-5-12 18:43:16

Also, it doesn’t seem to be working correctly, see: https://github.com/racket/typed-racket/pull/1095/checks#step:5:7 which should be using the local catalog


samth
2021-5-12 19:13:30

ben.knoble
2021-5-12 20:22:02

macro-defining macro shenanigans follow:

I’m writing a defmacro form to make it possible to write un-hygienic (or manually hygienic, I guess) macros à la Clojure/Common Lisp (think targeted at students with no time to explain Racket’s awesome-but-complex macro system). Some examples:

;; numeric if (defmacro (nif num-expr neg-expr z-expr pos-expr) (let ([num-sym (genysm)]) `(let ([,num-sym ,num-expr]) (cond [(negative? ,num-sym) ,neg-expr] [(zero? ,num-sym) ,z-expr] [(positive? ,num-sym) ,pos-expr])))) ;; anaphoric -> (defmacro (a-> e . exprs) (if (empty? exprs) e `(let ([that ,e]) (a-> ,(first exprs) ,@(rest exprs))))) Anyway, I have things mostly working (:crossed_fingers: ?) except gensym. The following version of nif from above works, except we have that pesky little hard-coded name for the binding:

(defmacro (nif num-expr neg-expr z-expr pos-expr) `(let ([num ,num-expr]) (cond [(negative? num) ,neg-expr] [(zero? num) ,z-expr] [(positive? num) ,pos-expr]))) But when I try the manually hygienic version with gensym, I get (from raco test):

defmacro.rkt:31:18: genysm: reference to an unbound identifier at phase: 1; the transformer environment in: genysm context...: /Applications/Racket v8.0/share/pkgs/compiler-lib/compiler/commands/test.rkt:371:27 /Applications/Racket v8.0/share/pkgs/compiler-lib/compiler/commands/test.rkt:373:0: call-with-summary .../private/map.rkt:40:19: loop /Applications/Racket v8.0/share/pkgs/compiler-lib/compiler/commands/test.rkt:1101:1: test body of "/Applications/Racket v8.0/share/pkgs/compiler-lib/compiler/commands/test.rkt" /Applications/Racket v8.0/collects/raco/raco.rkt:41:0 body of "/Applications/Racket v8.0/collects/raco/raco.rkt" body of "/Applications/Racket v8.0/collects/raco/main.rkt" Thoughts? (source attached)


ben.knoble
2021-5-12 20:23:22

I did eventually realize that to get empty? /first /rest working for a-> I had to (require (for-syntax racket)), but that didn’t fix gensym


ben.knoble
2021-5-12 20:24:46

And I think gensym works at syntax time, because (define-syntax (foo s) (datum->syntax s (gensym))) expands (and then gives an error about the gensym)


soegaard2
2021-5-12 20:25:39

What’s the difference between this defamacro and the builtin defmacro ?


ben.knoble
2021-5-12 20:25:42

Since Slack was dumb, here’s the source for defmacro:

(define-syntax defmacro (syntax-parser [(_ (name:id param:id ...) body:expr ...+) #'(define-syntax (name stx) (syntax-parse stx [(_ param ...) (datum->syntax stx (let ([param (syntax->datum #'param)] ...) body ...) stx)]))] [(_ (name:id param:id ... . varargs:id) body:expr ...+) #'(define-syntax (name stx) (syntax-parse stx [(_ param ... . varargs) (datum->syntax stx (let ([param (syntax->datum #'param)] ... [varargs (syntax->datum #'varargs)]) body ...) stx)]))]))


ben.knoble
2021-5-12 20:25:57

@soegaard2 there’s a builtin? :exploding_head:



ben.knoble
2021-5-12 20:26:21

well… nothing to see here… just a waste of an hour or two :slightly_smiling_face:


ben.knoble
2021-5-12 20:28:35

Still curious why this didn’t work, but at least I can stop working on it


soegaard2
2021-5-12 20:29:11

Maybe the code for the builtin contains a clue?


soegaard2
2021-5-12 20:29:16

But where is it …


ben.knoble
2021-5-12 20:29:48

ben.knoble
2021-5-12 20:34:20

No way—that builtin has the same issue.


capfredf
2021-5-12 20:36:51

genysm -> gensym


ben.knoble
2021-5-12 20:37:40

sigh thank you :tada: syntax highlighting wasn’t coloring, so I should have known…


soegaard2
2021-5-12 20:40:09

The secret sauce is the hash table keeping track of the relation between the generated syntax objects and the original syntax.


jagen315
2021-5-12 22:27:19

how stupid is this on a scale of 10 to 1, 1 being most: download sexpr over http in macro, write sexpr to module file, require module in current program


jagen315
2021-5-12 22:28:14

also why isnt background expansion allowed to do that


ben.knoble
2021-5-12 23:07:42

I cant comment on stupid, but it at least sounds fun, if possibly insecure. I bet Paul Graham would have thoughts from back in the via web days


samth
2021-5-12 23:57:26

Seems reasonable. Background expansion won’t do that because you don’t really want to continually make network requests in the background


jagen315
2021-5-13 00:36:42

ok. unfortunately it means I don’t get any ide features :disappointed:


jagen315
2021-5-13 00:44:34

paul graham would say “ah yes, I have about 16 of those requests in my most recent image, and they randomly run at compile time or run time based on how many layers of macros they are inside of, and the mood of the compiler on that particular day”


greg
2021-5-13 00:59:01

@jagen315 Do you mean Dr Racket background expansion, or something else? What sort of IDE features do you have in mind?


greg
2021-5-13 01:01:21

@samth I think it might depend? On the requests (e.g. is there a cache, is an existing connection reused vs. created each time, etc.). And can the user disable it? But I don’t understand the context.


samth
2021-5-13 01:02:31

I recommend a cache that allows you to read from disk without hitting the network every time. That will both make background expansion work and is probably what you want anyway


greg
2021-5-13 01:02:53

Oh is this something ~= Dr Racket does background expansion in a sandbox that disallows network I/O, or something like that??


jagen315
2021-5-13 01:03:55

@samth I agree, but I can’t because the background expander throws an error when I try to open the socket (or open the file)


greg
2021-5-13 01:03:58

(Also, sorry I didn’t mean to “butt in”, but background expansion and IDEs are relevant to my interests, so curious!)


jagen315
2021-5-13 01:04:22

no worries. not butting in


samth
2021-5-13 01:05:40

Opening a socket will indeed error


samth
2021-5-13 01:05:47

Opening a file for writing will too


samth
2021-5-13 01:06:00

But reading a file won’t


samth
2021-5-13 01:06:33

So if you click the run button the first time, then background expansion won’t need to use the network or write to a file and will succeed


jagen315
2021-5-13 01:06:36

oh I see. so I’d just have to run the program once, and then I’d get my drracket arrows


samth
2021-5-13 01:06:53

Exactly


samth
2021-5-13 01:07:04

Yes


samth
2021-5-13 01:07:20

Also writing to files


jestarray
2021-5-13 03:37:14

#lang racket (define width 2) (define height 3) (define lay 4) (define 3d (make-vector 2 (make-vector lay (make-vector (* width height) 0)))) (define (2d->1d x y w) (+ x (* w y))) (define (mut 3d-index) (define z (vector-ref 3d 3d-index)) (for ([y-index (range 0 height)]) (define row (vector-ref z y-index)) (for ([x-index (range 0 width)]) (define index-into-x (2d->1d x-index y-index width)) (vector-set! row index-into-x (random 0 20)) ))) (for ([i (range 0 (vector-length 3d))]) (mut i) (println i) (println (vector-ref 3d i))) (println "final") (println 3d) how come the final resulting vector is not what i expect? 0 '#(#(5 2 1 4 5 6) #(5 2 1 4 5 6) #(5 2 1 4 5 6) #(5 2 1 4 5 6)) 1 '#(#(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4)) "final" '#(#(#(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4)) #(#(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4))) ;what i expect is a combination of both stacked other like this: #(#(#(5 2 1 4 5 6) #(5 2 1 4 5 6) #(5 2 1 4 5 6) #(5 2 1 4 5 6)) #(#(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4) #(4 8 2 0 2 4))) this is a small snippet from a sort of complex program converting maps. I know it can be done a different way and done better but right now I just wanna know why the resulting vec isnt what i expect it.. I’m printing the state of the vec right before i print final but yet they’re different


jestarray
2021-5-13 04:42:08

seems like someone on the discord said that the vectors are aliasing each other! How was I supposed to know >__>…. should probably put a warning that nested (define v (make-vector 2 (vector))) might alias


popa.bogdanp
2021-5-13 05:40:29

> I think the local_catalogs feature is duplicating things: https://github.com/racket/typed-racket/pull/1095/checks?check_run_id=2569198853#step:3:45 I think that’s just an issue with the output. It’s showing both the output of the shell command as well as the console.logs from the action. I’ll push a fix.


popa.bogdanp
2021-5-13 06:25:31

OK, both problems are fixed in v1.3.1:

https://github.com/Bogdanp/typed-racket/runs/2573151117?check_suite_focus=true

The issue was that the action was only setting the catalogs in the user scope. Now it sets them in both scopes.


soegaard2
2021-5-13 06:37:56

That’s a rite of passage :slightly_smiling_face:

Everyone faces that the first time they represent a board with a vector of vectors.


sorawee
2021-5-13 06:53:36

I do think adjusting the documentation to include the word “share” and show an example about this tricky behavior is worthwhile