Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load a band like "mechanics.com" inside the Kernel environment? #21

Open
sritchie opened this issue May 23, 2020 · 3 comments
Open

Comments

@sritchie
Copy link

Hi!

I'm attempting to modify the kernel so that it's possible to get it running with all of the code from "SCMUtils" available to the user. At the repl, I can run a mechanics script like this:

#!/bin/bash
export MITSCHEME_HEAP_SIZE=100000
export MITSCHEME_BAND=mechanics.com
exec mit-scheme "${@}"

Or call

mit-scheme -band mechanics.com -heap 100000

I've tried modifying kernel.json to use these commands, and I've verified that on kernel startup, I can access functions from the mechanics.com band... but of course the code sent to the kernel for evaluation can't see this.

I'm not asking you to add support for this, of course! That is a major ask. But would you mind sending me any tips you have on where in the code I'd want to look to try and get the environment we use for kernel evaluation to know about some other library of functions?

Thank you so much!

@joeltg
Copy link
Owner

joeltg commented May 23, 2020

I think what you'll need to do is mess around in src/shared.scm - there's a structure called "session" defined there that holds session-specific data including the session environment, which is what gets passed into eval in src/kernel/execute.scm.

So theoretically this line is the one you care about - it's the initialization expression for the environment field of the session structure. I'm not sure how and where all the scmutils bindings are actually held (they're probably not in the top-level environment, and IIRC the whole way environments are nested in scmutils is kind of weird) but you can maybe poke around with the environment functions and see what you find. Or maybe you can use apropos or similar to directly locate the environment that a given symbol is bound in?

Hope this helps - and I wish I had more time to keep this in better shape!

@joeltg
Copy link
Owner

joeltg commented May 23, 2020

And let me know if you get scmutils working! I'd love to post a little help section to the readme in case other people end up trying the same thing.

@sritchie
Copy link
Author

Thanks for the response, @joeltg ! I will for sure, probably once I absorb more of the language, and figure out how the band thing interacts with environments.

I did just finish dockerizing scmutils: https://hub.docker.com/r/sritchie/mechanics
and mit-scheme: https://hub.docker.com/r/sritchie/mit-scheme

on the road to getting a nice up-to-date Dockerfile published for your work here. I'm still down to do that with scmutils, but I found that this issue hit me too: #17 and decided to wait for now.

Thanks for this excellent work! Hopefully we can get this up and running at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants