Re: Should the command-name simplifier be exported?
Lassi Kortela 20 Apr 2020 08:42 UTC
> The simplifier is an implementation detail that shouldn't be exported.
> If SRFI 193 is implemented on a GNU system, the implementation probably
> wants to use `program_invocation_short_name' and thus will not include
> an ad-hoc simplifier in its code that could be exported as well.
That's a fair point in favor of omitting it.
However, the SRFI allows `command-line` to be implemented as a parameter
object (which is useful so programmers can re-bind it to refer to
subcommands of the main command or remove already-processed arguments
from it, etc.) In this case, `command-name` should simplify whatever
name is returned by `(car (command-line))` in any given environment.
Since `program_invocation_short_name` is a constant, an implementation
that uses it and also implements `command-line` as a parameter would
have to write its own simplifier anyway.
`program_invocation_short_name` also doesn't solve the case when running
scripts with #! lines. If the OS command line is `fantastic-scheme
foo.scm a b c` then (command-name) should return "foo".
In practice, `program_invocation_short_name` seems to be equivalent to
basename. Most Scheme implementations probably already have a basename
procedure that could be repurposed.