
@accounts_slack has joined the channel

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:

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?

Within the r5rs code.

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

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

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

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

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
.

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

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
.

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

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

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).

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

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”.


I’m slightly disappointed that this doesn’t work

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

Thanks all.

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.

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

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

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

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

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.

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

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.

Okay, that makes some sense. Thanks

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

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

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?

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

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

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

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

Executable bits are needed to actually enter directories, IIRC.

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

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

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

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.