[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [FEATURE] List all available languages
From: |
Nala Ginrut |
Subject: |
Re: [FEATURE] List all available languages |
Date: |
Sat, 26 Jan 2013 00:46:26 +0800 |
On Fri, 2013-01-25 at 12:06 +0100, Andy Wingo wrote:
> On Fri 25 Jan 2013 11:43, Nala Ginrut <address@hidden> writes:
>
> > @@ -33,6 +33,9 @@
> >
> > (define-module (ice-9 command-line)
> > #:autoload (system vm vm) (set-default-vm-engine! set-vm-engine! the-vm)
> > + #:use-module (srfi srfi-1)
> > + #:use-module (ice-9 regex)
> > + #:use-module (ice-9 ftw)
> > #:export (compile-shell-switches
> > version-etc
> > *GPLv3+*
>
> For the reason given in the comment above this block, we cannot load
> these modules at startup. (Too expensive.) I suggest you make a little
> trampoline that does a module-ref at runtime like eval-string/lang.
>
Fixed with @ ;-)
> > +(define (not-inner-lang? str)
> > + (not (string-match
> > +
> > "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) not-inner-lang?)))
> > + (lp (cdr rest) (if ll (cons ll result) result)))))))
>
> This is pretty nasty :) First of all I would request that you have no
> tabs please and stick to the 80-char limit. But more substantially I
> would want a function that returns a list of symbols and calls
> lookup-language on them, recursively filtering out any language that is
> the target of another compiler.
>
Recursively filtering from compiler-tower? Wow, that's definitely an
excess way than mine ;-D
Are you sure that's worthy?
Users just need a way to know what languages could be specified to
--language option.
> > + ((string=? "--list-languages" arg) ; list all languages
> > + (for-each (lambda (l)
> > + (format #t "~a~%" l))
> > + (get-all-available-languages))
> > + (exit 0))
> > +
>
> Also this needs to respect the 80-character width, somehow.
>
> > +(define (valid-lang? str)
> > + (not (string-match
> > + "[A-Za-z0-9_ -]+\\.scm|\\.\\.|\\."
> > + 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) valid-lang?)))
> > + (lp (cdr rest) (if ll (cons ll result) result)))))))
> > +
>
> Why is this duplicated here?
>
> > + -l, --list-languages list all available languages
>
> Probably we don't need the short option.
>
All fixed.
Patch updated.
Thanks!
> Regards,
>
> Andy
0001-List-all-available-languages.patch
Description: Text Data
- [FEATURE] List all available languages, Nala Ginrut, 2013/01/23
- Re: [FEATURE] List all available languages, Nala Ginrut, 2013/01/25
- Re: [FEATURE] List all available languages, Mark H Weaver, 2013/01/25
- Re: [FEATURE] List all available languages, Mark H Weaver, 2013/01/25
- Re: [FEATURE] List all available languages, Nala Ginrut, 2013/01/25
- Re: [FEATURE] List all available languages, Andy Wingo, 2013/01/27
- Re: [FEATURE] List all available languages, Mark H Weaver, 2013/01/27