Hacker News new | ask | show | jobs
by Jtsummers 23 days ago
> I was astounded when I saw that you run programs using the live REPL.

That's one way, you stopped too early in your investigation though.

You can produce binaries, though the precise mechanism will vary by your implementation. And there's no reason to use the REPL for it. You can create an executable file with something like this:

  (defun main () ...) ; do whatever you need in here for program launch

  (sb-ext:save-lisp-and-die "my-program" :executable t :toplevel #'main)
And then `sbcl --load program.lisp` (or whatever you name it) and it'll produce a binary for you. Other implementations will have other methods of achieving the same thing.

Or, if you don't need a binary, you can have something like this:

  (defun main () ...)

  (main)
And then run `sbcl --load program.lisp`. That will compile and execute it without ever invoking the REPL.

(NB: Using a function named main isn't strictly necessary, I named it that for the example. Name it whatever you want.)

1 comments

Thank you, that's very helpful to know!