
update: I was able to get this to work using index*

Call for help: if you are interested in entering the<https://icfpcontest2020.github.io/#/| icfp contest 2020 >and using racket - Participation requires using an approved docker container that mostly seems to require a specific format and can’t need an internet connection to work. • The good news is there is already a dockerised version of racket - both on docker and repo https://github.com/jackfirth/racket-docker https://github.com/icfpcontest2020/dockerfiles/issues/63#issuecomment-658656973

I’m experiencing a problem submitting a PR to Racket. In particular, it doesn’t know that my PR can be merged.

Here’s a discussion of background expansion for Rust in IntelliJ: https://blog.jetbrains.com/clion/2020/07/intellij-rust-0-3-new-macro-expansion-engine/

@samth: is it OK if I ask people (or actually, you) to try submitting a PR?


Seems like there’s an issue with GitHub Actions right now


I’m trying to start a repl at the end of a module, but this doesn’t seem to be enough: #lang racket
(define var 10)
(define-namespace-anchor a)
(define ns (namespace-anchor->namespace a))
(parameterize ([current-eval (λ (x) (eval x ns))])
(read-eval-print-loop))
It prompts, but does not respond. What’s missing?

Reading the doc, I don’t think your current-eval
is right

> A parameter that determines the current evaluation handler. The evaluation handler is a procedure that takes a top-level form and evaluates it, returning the resulting values. The evaluation handler is called by eval

It looks like the handler should be something more primitive than eval
, so calling eval
seems wrong to me

This works FWIW:

#lang racket
(require racket/sandbox)
(parameterize ([current-eval (make-evaluator 'racket/base)])
(read-eval-print-loop))

Thanks. Sounds like you’re right, I was misled by the name

I’ll just use my own repl instead: #lang racket
(define var 10)
(define (namespace-anchor->repl a)
(define ns (namespace-anchor->namespace a))
(define (repl)
(display "> ")
(with-handlers ([exn:fail? (λ (e) (displayln (exn-message e))
(repl))])
(define str (read-line))
(unless (eof-object? str)
(define xs
(with-input-from-string (string-append "(" str ")")
read))
(for ([x (in-list xs)])
(writeln (eval x ns)))
(repl))))
repl)
(define-namespace-anchor a)
(define repl (namespace-anchor->repl a))
(repl)

Probably need with-handlers
to avoid error from both read
and eval
?

Also, what will happen when the input is 1 2
?

that’s all fine, it’s not for anyone else’s use :stuck_out_tongue:

but yeah, it could be made more robust

There ought to be a REPL functionality in Racket that does precisely all this though. Maybe it’s hidden somewhere?

Alright, you got me, code above edited.


@laurent.orseau If you want a new eval handler that chains to the old one, you can use something like (parameterize ([current-eval (let ([old-eval (current-eval)])
(λ (x) ... (old-eval x) ...))])
....)
But for read-eval-print-loop
, it turns out that the eval handler is too late to set the namespace, because the eval
uses the current namespace with namespace-syntax-introduce
before calling the eval handler. You may need something more like (parameterize ([current-namespace ns])
(read-eval-print-loop))
or a combination of current-namespace
and current-eval
.

not exactly, this is a gui repl, I need a cmd line one

thanks though :)

Thanks. Just parameterizing the current-namespace doesn’t seem to be enough, it still hangs on reading

(or before printing at least)

I see that, too, in DrRacket. I was trying command-line Racket before, and i’m not sure why DrRacket is different.

any chance https://github.com/racket/drracket/issues/371 is related, and then possibly simpler to diagnose

@laurent.orseau: parameterizing current-namespace
works for me.

Could someone from the Racket team review this pull request for me? https://github.com/racket/plot/pull/62

I haven’t read the implementation yet but this sounds awesome.