mit-scheme-kernel icon indicating copy to clipboard operation
mit-scheme-kernel copied to clipboard

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

Open sritchie opened this issue 4 years ago • 3 comments

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!

sritchie avatar May 23 '20 12:05 sritchie

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 avatar May 23 '20 16:05 joeltg

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.

joeltg avatar May 23 '20 17:05 joeltg

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: https://github.com/joeltg/mit-scheme-kernel/issues/17 and decided to wait for now.

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

sritchie avatar May 23 '20 18:05 sritchie