command? and script? predicates
Lassi Kortela 20 Apr 2020 07:40 UTC
Suggestion from Arthur:
> Would it make sense, or even be possible, to make a procedure that returns the symbol command or script depending on which it is?
A program can be both a command and a script at the same time. Therefore
it would be simpler to have two predicates: `command?` and `script?`. I
left them out since testing for a #f return value from `command-name`,
`script-file`, or `script-directory` accomplishes the same goal.
`command` and `script` are also such common words that it would be nice
to reserve those procedures for users. For example, if a Scheme program
has its own command datatype, it's nice if `command?` can refer to that.
Then again, I guess that would be nice with `command-name` as well.
Currently one can write code like this:
(define csv-file
(or (and (script-directory)
(string-append (script-directory) "data.csv"))
(get-environment-variable "CSV_FILE")
(error "Cannot find CSV file")))
We can add the explicit predicates if there is demand.