Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

passing command line arguments to shen-sbcl.exe

89 views
Skip to first unread message

Joel McCracken

unread,
Aug 1, 2024, 11:39:48 AM8/1/24
to qil...@googlegroups.com
Last night I was trying to experiment and found myself having trouble with starting shen with a static script to execute from the command line, e.g. something like:

./shen-sbcl.exe <<EOF
 (+ 1 2)
EOF

Is there some kind of way to execute a shen script directly from the command line? If not directly, does anyone have experience with expect and shen?

I do notice that shen's primitives don't exactly facilitate this, so I am wondering how much I need to build myself.

TY!

dr.mt...@gmail.com

unread,
Aug 4, 2024, 9:09:53 AM8/4/24
to Shen
I see nobody has yet come back on this.  
There is no provision within Shen for 
execution from the REPL apart from loading
a file which will execute all the Shen instructions
contained in it.

On the other hand if you want to execute a
Shen program from the OS then you need
to build an executable file.   The way this works
depends on the port and the OS.  The Shen/tk
download shows how to do this for Windows.  
OTOH assuming you are using Linux you might
do it differently.

Mark

Joel McCracken

unread,
Aug 5, 2024, 1:05:13 PM8/5/24
to qil...@googlegroups.com
Thanks. I've been looking around a bit at different things to figure out how to resolve this. The main thing I'm struggling with at the point is a lack of familiarity with CL/SBCL; While i've done a fair amount of scheme, racket, and emacs lisp over the years, I've done rather little SBCL. It looks to me like I would likely want to alter shen.shen function to have some additional context/initialization before starting the repl. Tho, if simple shell redirecting worked, that would probably solve it =\

It would probably be wiser to either learn SBCL and handle it at that level, or see if I can use https://github.com/Shen-Language/shen-sources/blob/master/extensions/launcher.shen to do what I want. I did have some trouble with the shen-scheme implementation, (tho I don't remember off the top of my head what it was), so I set the scheme version aside and tried the official SBCL release, which I was able to get working quite easily (though, it interacts poorly with expect script termination, but that's clearly specific to SBCL behavior).

Overall I'm trying to come up with some nice ways to interact with the shen builds to speed things up as I experiment with changing the kernel sources. I was experimenting with getting the kernel to compile shen into klambda while improving the names it chooses for parameters/let bindings; while trying to figure out how to use shen-elisp, it was frustrating jumping to look at functions and seeing the klambda source then translated to elisp.

I'm knee-deep in yak hair, but slowly I'm working my way through the queue of yaks. Things are making more sense in general.

Thanks!


--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/qilang/88308b11-7303-433d-ae21-c1e3333bf68cn%40googlegroups.com.

dr.mt...@gmail.com

unread,
Aug 5, 2024, 7:43:51 PM8/5/24
to Shen
I think you need to look at this.


p 9. onwards may help.

Mark

Bruno Deferrari

unread,
Aug 6, 2024, 10:43:59 AM8/6/24
to qil...@googlegroups.com
On Mon, Aug 5, 2024 at 2:05 PM Joel McCracken <mccrack...@gmail.com> wrote:
Thanks. I've been looking around a bit at different things to figure out how to resolve this. The main thing I'm struggling with at the point is a lack of familiarity with CL/SBCL; While i've done a fair amount of scheme, racket, and emacs lisp over the years, I've done rather little SBCL. It looks to me like I would likely want to alter shen.shen function to have some additional context/initialization before starting the repl. Tho, if simple shell redirecting worked, that would probably solve it =\

It would probably be wiser to either learn SBCL and handle it at that level, or see if I can use https://github.com/Shen-Language/shen-sources/blob/master/extensions/launcher.shen to do what I want. I did have some trouble with the shen-scheme implementation, (tho I don't remember off the top of my head what it was), so I set the scheme version aside and tried the official SBCL release, which I was able to get working quite easily (though, it interacts poorly with expect script termination, but that's clearly specific to SBCL behavior).


You can use launcher.shen if you want for the SBCL port to handle command line arguments in the same way as Shen/Scheme or the older Common Lisp port on GitHub (see https://github.com/Shen-Language/shen-cl/blob/ba6b1fc2635b951b461c94a9a1a8337d1ef0bd93/src/primitives.lsp#L366-L387 )
 
But for your specific use case (accepting script files as arguments) a new Common Lisp function that checks `sb-ext:*posix-argv*` to see if there are extra arguments and react accordingly by loading the files (and if none, just call `shen.shen`) should be enough.

Then in install.lsp replace the `shen.shen` :TOPLEVEL argument with your new function.


Btw if you remember which issue you were having with Shen/Scheme let me know (here or open an issue in the GitHub repository).
 
Reply all
Reply to author
Forward
0 new messages