

LLVM is usually considered a bad fit if your language is not close to C/C++

@samth @mflatt Is there a way to get C objects in a shared library to use the Racket GC?

Use the Racket CS in what way? Register roots that the GC will traverse and update?

So, I was thinking about getting a project going whereby a #lang
implementing a small subset of racket compiles down to C, and exports all the defined function using the ffi so that they are provided to those requiring modules written in such lang. I would of course need a GC in such a C translation so I was wondering if I can hijack the Racket GC to use in the translated code. In the end this compiled C code will always run under a Racket process, therefore there’s already a GC running.

For the traditional Racket implementation, yes: The GC API is generally exported by Racket. For example, there’s racket_malloc
, and there are macros like MZ_GC_DECL_REG
to temporarily register roots (such as references in stack-allocated memory). For Racket-on-Chez, not so much.

Is there a nice way to modify a module, reload it in the repl and test some functions in the repl? I have this weird and inconvenient thing to execute so far: (dynamic-rerequire "utils.rkt")
(require "utils.rkt")
(dynamic-rerequire "tokenizer.rkt")
(require "tokenizer.rkt")
(dynamic-rerequire "parser.rkt")
(require "parser.rkt")
(dynamic-rerequire "interpreter.rkt")
(require "interpreter.rkt")
each time I modify a module somewhere. It would be nice if the modules where reloaded automatically so that we only have the latest version of the code loaded in the repl

Is it possible to do it somehow?

Well, apparently, (require racket/rerequire)
(require racket/enter)
(enter! "some_module.rkt")
does the job!

@contact I wonder if the module reloadable
works in the REPL

@macocio Well, so far, by typing (enter! "module.rkt")
it reloads the code that’s enough for me!

@contact Ok, reloadable reloads it automatically when the file is saved.

That’s a shame since if the future is Racket-on-Chez, I would like to plan for that.

Is the Chez GC a precise GC as well? I assume it’s a completely different implementation of standard Racket.

Yes, Chez Scheme’s GC is precise. It’s more tightly bound to Scheme object representations than Racket’s GC. You can call Chez Scheme functions from C https://cisco.github.io/ChezScheme/csug9.5/foreign.html#./foreign:h8 and depending on what you want to do, that may work fine. Roughly, a GC will not happen while you’re in C code. Racket’s GC can fire on any allocation, while Chez Scheme’s GC fires through an asynchronous callback only while running Scheme code.