Is it possible to either create a variable that persists until the Racket VM shuts down or get a list of all of the libraries that are shared libraries that are currently being linked against the racket vm?
The reason why I ask is because I created a `from-c` require form[1], which takes in a C implementation of a module, compiles it, links it, and then loads the module. So using it would look something like this: #lang racket/base (require zordoz (from-c "foo.c")) However, it seems very unsafe to just recompile link and load the c file every time a module is run, because if the module is changed, the old version of the module will still remain. Worse still, it could cause the program to crash. And it's not trivial to unload the linked library and reload it at run time. So, I want to test if the module has already been compiled and linked, if so, skip the compile process and just load the module. (Or if the c file was modified throw an error telling the user to restart the VM.) In order to do this, I either need to use a list of all of the shared libraries linked with the Racket VM, or make that list myself. Now, I tried putting that list in the module, and just mutating it whenever a file is loaded[2]. This, however, doesn't work in an environment like DrRacket where it uses a sandbox to emulate a new racket environment, but it is still technically running in the same vm. (It fails because the module seems to get reloaded, and thus the list gets reset.) Thus, is there a way I can get a list of all of the currently linked libraries, or create a persistent variable that lasts as long as the VM is running? The `current-standard-link-libraries`[3] parameter doesn't work here because it only lists the standard libraries that are linked to the VM, and thus not ones that are loaded with `link-extension`. As a side note, an alternative approach I took to this problem was to compile a fresh version of the library with a new file name every single time the require form was run. (Which would create a bunch of extra files, but ideally those could be deleted when the VM shuts down. Again, kind of odd, but I wouldn't use this `from-c` think in anything besides quick tests anyway, so I don't think it matters too much.) I made an implementation of that here[4] (there are a few bugs in the counting code for creating new files, and it currently just stays at 0. That's not the problem though.) Whenever I use this code, to require something `from-c`, I get the following error: load-extension: expected module not found expected: syntax-grabber-0 found: module `syntax-grabber' path: /Users/leif/compiled/native/x86_64-macosx/3m/syntax-grabber-0.dylib Which is odd, because the `names` variable is in fact `syntax-grabber`, not `syntax-grabber-0`. And when I run this code in a `begin-for-syntax` rather than a `make-require-transformer` it works fine. So is there anyway I can either: (a) Get a list of all of the shared objects that are currently linked against the VM (ideally without using the FFI), (b) Keep a variable that persists until the VM terminates, (c) or load a module who's file name differs from the module it instantiates? Thank you. [1]: http://pasterack.org/pastes/11082 [2]: http://pasterack.org/pastes/36865 [3]: http://docs.racket-lang.org/dynext/Linking.html?q=dynext%2Flink#%28def._%28%28lib._dynext%2Flink..rkt%29._current-standard-link-libraries%29%29 [4]: http://pasterack.org/pastes/63016 ~Leif Andersen -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.