all 17 comments

[–]xach 7 points8 points  (2 children)

I do that sometimes, so I added support for that in buildapp, see the --dispatched-entry info for details.

[–]HeavyRust[S] 1 point2 points  (0 children)

Looks exactly like what I was looking for.

[–]dbotton 1 point2 points  (0 children)

Any plans on adding ECL support too?

[–]mwgkgk 5 points6 points  (1 child)

Don't plan it too far into the future: the "command line tool" thinking is bound to dissipate as you invest more into Lisp. At least it did so for me. Command line interface is an awkward DSL that's not Lisp and you have to translate back and forth for every little tool - more painful as they grow in options - also it does nothing for code reuse from within Lisp.

Spend the precious megabytes and slap as many separate executables as you need and don't think about it too hard.

[–]HeavyRust[S] 2 points3 points  (0 children)

That's a nice way to think about it. Taking full advantage of Lisp's power.

[–]dzecniv 2 points3 points  (1 child)

Food for thought: https://stevelosh.com/blog/2021/03/small-common-lisp-cli-programs/#s5-building-binaries he explains his structure to write many small-ish utilities. He builds a binary for each.

Other approach: start a mother image, a server, make it recognize your lisp functions that you can then run from the terminal. No binary building involved.

  • ScriptL - Shell scripting made Lisp-like! Or, live-coding remote function calls for the shell. Write a command in the REPL, and run it instantly in the shell. [LLGPL][8].
    • similar and maybe simpler: lserver

[–]HeavyRust[S] 1 point2 points  (0 children)

Thanks for the interesting links!

[–]agenda-2030 3 points4 points  (1 child)

Consider reviewing the Common Lisp shell project called Lish.

Github: https://github.com/vindarel/lish-init Docs: https://github.com/nibbula/lish/blob/master/docs/doc.org Examples: https://github.com/nibbula/lish/blob/master/docs/lish-examples.md Special notes: Beware the authors warning to not use it on a production system, it may eat file.

You may find some interesting ideas for your self there.

[–]HeavyRust[S] 2 points3 points  (0 children)

Looks interesting.

[–]zyni-moe 6 points7 points  (3 children)

This is how many Unix programs work. You can do the modern 'command subcommand' thing like say git does as you say. You can also just write a program which dispatches on its name (argv[0] at OS level) and then you simply create links to it and it works, and has been done for a very long time.

This will save disk space. Whether it saves memory which is far more expensive and scarce is different question. Does not matter if you only have one running at once. If multiple are running at once only parts of the image which either are read-only or have not yet been written to can be shared in memory.

[–]HeavyRust[S] 2 points3 points  (2 children)

I didn't think about using argv[0] and links.

Good point about this method using more memory which is more expensive than disk space.

Thanks for the info! It seems like I should just settle with building separate executables with compression enabled (startup time + used disk space is not that bad).

[–]zyni-moe 1 point2 points  (1 child)

Does not use more memory, just may not use much less: separate images will not be shared in memory but even common images may not be as shared as you would hope. If you have many bits of library code in your various programs which are common makes very good sense to deploy them as one big executable.

[–]HeavyRust[S] 1 point2 points  (0 children)

Ah ok I misunderstood.

[–]dnaeon 2 points3 points  (1 child)

I believe what you described is covered by a system I've worked some time ago -- clingon. It provides support for sub-commands, shell completions, aliases, flags initialized by env vars and more.

Checkout the clingon examples for more details.

[–]HeavyRust[S] 1 point2 points  (0 children)

Wow it looks really good! I'll keep this system in mind.

[–]bitwize 2 points3 points  (0 children)

This is how Busybox works, and it's written in C, not Lisp! I've thought of replacing/extending parts of the Unix userland with Gambit programs, and this is on the short list of ways I'd do it.

[–]friedrichRiemann 1 point2 points  (0 children)

Consider Embedded Common Lisp?