As I talked with Andy, we may add a feature to list all available
languages. And if users add a new language to the %load-path, they may
see it listed out. Besides, this feature could be used in 'guild
compile' to detect all the language available.
Attached is a proc named 'get-all-available-languages', it'll scan all %
load-path and list the union of the languages available.
Please review it.
If accepted, I'll format a patch into (ice-9 command-line).
Thanks!
(use-modules (ice-9 ftw) (srfi srfi-1))
(define (is-inner-lang? str)
(and
(not (member str
'("glil" "glil.scm" "assembly" "assembly.scm" "bytecode" "objcode.scm" "objcode"
"tree-il" "tree-il.scm" "value" ".." ".")))
str))
(define (get-all-available-languages)
(let lp((rest (map (lambda (x) (string-append x "/language")) %load-path)) (result '()))
(cond
((null? rest) (apply lset-union string=? result))
(else
(let ((ll (scandir (car rest) is-inner-lang?)))
(lp (cdr rest) (if ll (cons ll result) result)))))))