accounts_slack
2022-1-6 14:45:12

@accounts_slack has joined the channel


accounts_slack
2022-1-6 14:54:43

Hi everybody. I am trying to write r5rs code and export it as a racket module. Up until now, I used #lang r5rs to do this. However, I need to be able to re-define pre-defined functions (i.e. I need to be able to get the --no-prim behaviour). https://docs.racket-lang.org/r5rs/r5rs-mod.html told me I can use (namespace-require/copy 'r5rs) to achieve this. However, I haven’t been able to get this to work. Particularly, I am not sure which #lang or (module …) form I must use.

Using something like #lang racket (namespace-require/copy 'r5rs) Does not work. Could somebody help me out please? :slightly_smiling_face:


soegaard2
2022-1-6 15:00:14

That section begins: > The https://docs.racket-lang.org/r5rs/r5rs-mod.html\|r5rs bindings can be imported into a top-level environment, I think the author had the repl in mind here.

Do you need to re-define the predefined functions within the R5RS code, or in code that requires your code?


accounts_slack
2022-1-6 15:01:08

Within the r5rs code.


soegaard2
2022-1-6 15:02:00

I’ll need to test that. I thought (set! + -) worked out of the box in the #lang r5rs.


sorawee
2022-1-6 15:03:45

Actually, it doesn’t work out of the box.


soegaard2
2022-1-6 15:04:01

#lang r5rs (define + -) (display (+ 2 3)) (newline) (set! + *) (display (+ 2 3))


soegaard2
2022-1-6 15:04:24

You’ll need to use define before you use set!.


sorawee
2022-1-6 15:04:43

Are you using DrRacket?

The r5rs language from the language choosing dialog has the option “Disallow redefinition of initial bindings”, which is on by default.

You can uncheck it, and this corresponds to --no-prim.


sorawee
2022-1-6 15:05:05

With that, (set! + -) works fine even without (define + ...)


accounts_slack
2022-1-6 15:06:59

I’m using racket on the command line (we are doing automated testing on students code). There are some differences between #lang r5rs and just plt-r5rs --no-prim which are proving troublesome: (define + -) (define + /) Works in “plain” r5rs, but not. in #lang r5rs.


sorawee
2022-1-6 15:07:26

Right, so is there a reason you don’t want to use plt-r5rs --no-prim?


accounts_slack
2022-1-6 15:09:55

We are mainly using racket instead of plt-r5rs since we’d like to support other scheme standards in the future.


accounts_slack
2022-1-6 15:11:32

So it was a logical starting point. I noticed early on that there were some differences between #lang r5rs and racket, but they were not a showstopper until now. (I am expanding the tool we use for another course, which also uses r5rs).


accounts_slack
2022-1-6 15:11:50

As a side note, does plt-r5rs respect environment variables such as PLTCOLLECTS?


soegaard2
2022-1-6 15:14:36

A low-tech solution: Add (define + +) etc to the start of the student files.

But since you are running the code from the testing tool, it must be possible to figure out an equivalent of “Disallow redefinition of initial bindings”.



sorawee
2022-1-6 15:15:52

I’m slightly disappointed that this doesn’t work


sorawee
2022-1-6 15:15:55

#lang racket/load (require r5rs/init) ADD1


accounts_slack
2022-1-6 15:19:21

Thanks all.


accounts_slack
2022-1-6 15:21:04

I’m considering going through the pain of switching to plt-r5rs now instead of adding hack after hack to deal with the differences between #lang r5rs and plt-r5rs. Might be the solution in the long term.


accounts_slack
2022-1-6 15:21:25

Though I’ll take a look at @samth’s suggestion first


soegaard2
2022-1-6 15:23:46

FWIW the lines that handle —no-prim are here: https://github.com/racket/r5rs/blob/master/r5rs-lib/r5rs/run.rkt#L6


soegaard2
2022-1-6 15:26:29

It looks like it sets up the environment, uses load to run the file and then sets up a repl.


soegaard2
2022-1-6 15:28:06

That is, it doesn’t treat the file as a racket module.


accounts_slack
2022-1-6 15:28:35

Yes. I just don’t get how (namespace-require/constant 'r5rs/init)) works in that context. If I use such a require in e.g. #lang scheme/base I cannot access set-car! or similar functions.


sorawee
2022-1-6 15:29:39

It essentially requires the “host” file to setup a namespace and configurations, which then load / dynamic-require / etc the actual code to run.


accounts_slack
2022-1-6 15:30:06

Although if I do something like: #lang scheme/base (namespace-require/copy 'r5rs) (load "test.rkt") it does work. So I guess namespace-require combined with load is what does the trick.


accounts_slack
2022-1-6 15:30:19

Okay, that makes some sense. Thanks


sorawee
2022-1-6 15:30:41

Btw, scheme/base is not recommended. You can just write racket/base instead.


soegaard2
2022-1-6 15:31:44

The scheme doesn’t refer to r5rs but to the old mzscheme language. It’s only used for legacy code.


philip.mcgrath
2022-1-6 18:20:29

For the last couple days, when building Racket locally or via CI, I’ve intermittently seen errors like this: Downloading repository <git://github.com/racket/serialize-cstruct-lib> commit cabf4188a34c70af2f6a376fc3b0f55d035a2ab7 open-input-output-file: error opening file path: /var/tmp/git16414925351641492535961/objs-small system error: Permission denied; errno=13 context...: /home/philip/code/tmp/racket/racket/collects/net/git-checkout.rkt:1003:0 /home/philip/code/tmp/racket/racket/collects/net/git-checkout.rkt:74:8 /home/philip/code/tmp/racket/racket/collects/net/git-checkout.rkt:55:2: retry-loop /home/philip/code/tmp/racket/racket/collects/pkg/private/download.rkt:102:2: download! /home/philip/code/tmp/racket/racket/collects/file/cache.rkt:63:2: fetch-and-continue /home/philip/code/tmp/racket/racket/collects/racket/contract/private/arrow-val-first.rkt:555:3 /home/philip/code/tmp/racket/racket/collects/pkg/private/download.rkt:94:0: download-repo! /home/philip/code/tmp/racket/racket/collects/pkg/private/stage.rkt:318:11 /home/philip/code/tmp/racket/racket/collects/pkg/private/stage.rkt:114:0: stage-package/info [repeats 1 more time] /home/philip/code/tmp/racket/racket/collects/pkg/private/install.rkt:141:0: install-packages /home/philip/code/tmp/racket/racket/collects/pkg/private/install.rkt:925:4 /home/philip/code/tmp/racket/racket/collects/racket/contract/private/arrow-val-first.rkt:555:3 /home/philip/code/tmp/racket/racket/collects/racket/file.rkt:775:8 /home/philip/code/tmp/racket/racket/collects/racket/file.rkt:764:0: call-with-file-lock /home/philip/code/tmp/racket/racket/collects/pkg/main.rkt:216:16 ... Is this a known problem?


samth
2022-1-6 18:24:25

I have intermittently seen a failure in this test http://drdr.racket-lang.org/59375/pkgs/racket-test-extra/tests/ffi/serialize-cstruct.rkt which might or might not be related


philip.mcgrath
2022-1-6 18:28:30

Here’s a CI run on Mac where the error comes while downloading db-test: https://github.com/racket/racket/runs/4725766846?check_suite_focus=true


philip.mcgrath
2022-1-6 18:39:17

Oh, actually, maybe this is a bug in my make-temporary-file changes …


philip.mcgrath
2022-1-6 18:44:19

It’s my own bug: I was creating directories with mode #o600, but actually the user-execute-bit is also needed.


ben.knoble
2022-1-6 19:46:42

Executable bits are needed to actually enter directories, IIRC.


notjack
2022-1-6 21:01:25

Rhombus meeting today! We’re talking about the Wraith syntax proposal.

Agenda: https://github.com/racket/rhombus-prototype/discussions/180#discussioncomment-1906080 Zoom link: https://utah.zoom.us/j/96590513005


jagen315
2022-1-7 03:18:25

hmm I tried to search for rsound in the docs and I cannot find it. I can find the docs at https://docs.racket-lang.org/rsound@rsound/ but why are they in this weird place and not searchable


samth
2022-1-7 03:58:23

I think the rsound build broke due to a dependency error. I think it will be fixed relatively soon


wjb
2022-1-7 04:02:09

Does raco support installing private github repos? I tried setting up a deploy key and using ssh_config to force its use, but that didn’t work. I assume raco isn’t using the ssh interface.