* [FEATURE] List all available languages @ 2013-01-23 11:28 Nala Ginrut 2013-01-25 9:56 ` Nala Ginrut 0 siblings, 1 reply; 12+ messages in thread From: Nala Ginrut @ 2013-01-23 11:28 UTC (permalink / raw) To: guile-devel [-- Attachment #1: Type: text/plain, Size: 469 bytes --] 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! [-- Attachment #2: lang.scm --] [-- Type: text/x-scheme, Size: 560 bytes --] (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))))))) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-23 11:28 [FEATURE] List all available languages Nala Ginrut @ 2013-01-25 9:56 ` Nala Ginrut 2013-01-25 10:43 ` Nala Ginrut 0 siblings, 1 reply; 12+ messages in thread From: Nala Ginrut @ 2013-01-25 9:56 UTC (permalink / raw) To: guile-devel [-- Attachment #1: Type: text/plain, Size: 620 bytes --] On Wed, 2013-01-23 at 19:28 +0800, Nala Ginrut wrote: > 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! I think Regular Expression would better choice ;-p New patch attached. [-- Attachment #2: lang.scm --] [-- Type: text/x-scheme, Size: 542 bytes --] (use-modules (ice-9 ftw) (srfi srfi-1)) (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))))))) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 9:56 ` Nala Ginrut @ 2013-01-25 10:43 ` Nala Ginrut 2013-01-25 11:06 ` Andy Wingo 0 siblings, 1 reply; 12+ messages in thread From: Nala Ginrut @ 2013-01-25 10:43 UTC (permalink / raw) To: guile-devel [-- Attachment #1: Type: text/plain, Size: 103 bytes --] Here is a patch to provide listing all languages for 'guile' and 'guild compile' command. Thanks! [-- Attachment #2: 0001-List-all-available-languages.patch --] [-- Type: text/x-patch, Size: 4907 bytes --] From f06fcd9e997e0bd6de9f85c22d75bd7a05545627 Mon Sep 17 00:00:00 2001 From: Nala Ginrut <nalaginrut@gmail.com> Date: Fri, 25 Jan 2013 18:38:22 +0800 Subject: [PATCH] List all available languages. * ice-9/command-line.scm: list available languages for 'guile' cmd. * scripts/compile.scm: list all available languages for 'guild compile' cmd. * NOTE: 'guile --list-languages' won't list inner languages, but 'guild compile -l' will do that. --- module/ice-9/command-line.scm | 23 +++++++++++++++++++++++ module/scripts/compile.scm | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm index 2aa50ec..57d93c7 100644 --- a/module/ice-9/command-line.scm +++ b/module/ice-9/command-line.scm @@ -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+* @@ -122,6 +125,7 @@ If FILE begins with `-' the -s switch is mandatory. -e FUNCTION after reading script, apply FUNCTION to command line arguments --language=LANG change language; default: scheme + --list-languages list all available languages -ds do -s script at this point --debug start with the \"debugging\" VM engine --no-debug start with the normal VM engine (backtraces but @@ -189,6 +193,19 @@ If FILE begins with `-' the -s switch is mandatory. ((module-ref (resolve-module '(system base compile)) 'compile-file) f #:to 'value)))) +(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))))))) + (define* (compile-shell-switches args #:optional (usage-name "guile")) (let ((arg0 "guile") (script-cell #f) @@ -306,6 +323,12 @@ If FILE begins with `-' the -s switch is mandatory. (cons `(current-language ',(string->symbol (car args))) out))) + ((string=? "--list-languages" arg) ; list all languages + (for-each (lambda (l) + (format #t "~a~%" l)) + (get-all-available-languages)) + (exit 0)) + ((string=? arg "-ds") ; do script here ;; We put a dummy "load" expression, and let the -s put the ;; filename in. diff --git a/module/scripts/compile.scm b/module/scripts/compile.scm index 20db944..7e74eb9 100644 --- a/module/scripts/compile.scm +++ b/module/scripts/compile.scm @@ -35,6 +35,8 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-13) #:use-module (srfi srfi-37) + #:use-module (ice-9 regex) + #:use-module (ice-9 ftw) #:use-module (ice-9 format) #:export (compile)) @@ -45,6 +47,19 @@ (format (current-error-port) "error: ~{~a~}~%" messages) (exit 1)) +(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))))))) + (define %options ;; Specifications of the command-line options. (list (option '(#\h "help") #f #f @@ -80,6 +95,12 @@ (option '(#\O "optimize") #f #f (lambda (opt name arg result) (alist-cons 'optimize? #t result))) + (option '(#\l "list-languages") #f #f + (lambda (opt name arg result) + (for-each (lambda (l) + (format #t "~a~%" l)) + (get-all-available-languages)) + (exit 0))) (option '(#\f "from") #t #f (lambda (opt name arg result) (if (assoc-ref result 'from) @@ -157,6 +178,7 @@ Compile each Guile source file FILE into a Guile object. -W, --warn=WARNING emit warnings of type WARNING; use `--warn=help' for a list of available warnings + -l, --list-languages list all available languages -f, --from=LANG specify a source language other than `scheme' -t, --to=LANG specify a target language other than `objcode' -T, --target=TRIPLET produce bytecode for host TRIPLET -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 10:43 ` Nala Ginrut @ 2013-01-25 11:06 ` Andy Wingo 2013-01-25 16:46 ` Nala Ginrut 2013-01-25 20:06 ` Mark H Weaver 0 siblings, 2 replies; 12+ messages in thread From: Andy Wingo @ 2013-01-25 11:06 UTC (permalink / raw) To: Nala Ginrut; +Cc: guile-devel On Fri 25 Jan 2013 11:43, Nala Ginrut <nalaginrut@gmail.com> 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. > +(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. > + ((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. Regards, Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 11:06 ` Andy Wingo @ 2013-01-25 16:46 ` Nala Ginrut 2013-01-31 10:32 ` Andy Wingo 2013-01-25 20:06 ` Mark H Weaver 1 sibling, 1 reply; 12+ messages in thread From: Nala Ginrut @ 2013-01-25 16:46 UTC (permalink / raw) To: Andy Wingo; +Cc: guile-devel [-- Attachment #1: Type: text/plain, Size: 2790 bytes --] On Fri, 2013-01-25 at 12:06 +0100, Andy Wingo wrote: > On Fri 25 Jan 2013 11:43, Nala Ginrut <nalaginrut@gmail.com> 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 [-- Attachment #2: 0001-List-all-available-languages.patch --] [-- Type: text/x-patch, Size: 4223 bytes --] From a6b321e51a19d3726620a68f8db4902877872460 Mon Sep 17 00:00:00 2001 From: Nala Ginrut <nalaginrut@gmail.com> Date: Fri, 25 Jan 2013 18:38:22 +0800 Subject: [PATCH] List all available languages. * ice-9/command-line.scm: list available languages for 'guile' cmd. * scripts/compile.scm: list all available languages for 'guild compile' cmd. * NOTE: 'guile --list-languages' won't list inner languages, but 'guild compile -l' will do that. --- module/ice-9/command-line.scm | 23 +++++++++++++++++++++++ module/scripts/compile.scm | 13 +++++++++++++ 2 files changed, 36 insertions(+) diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm index 2aa50ec..60a1eee 100644 --- a/module/ice-9/command-line.scm +++ b/module/ice-9/command-line.scm @@ -122,6 +122,7 @@ If FILE begins with `-' the -s switch is mandatory. -e FUNCTION after reading script, apply FUNCTION to command line arguments --language=LANG change language; default: scheme + --list-languages list all available languages -ds do -s script at this point --debug start with the \"debugging\" VM engine --no-debug start with the normal VM engine (backtraces but @@ -189,6 +190,22 @@ If FILE begins with `-' the -s switch is mandatory. ((module-ref (resolve-module '(system base compile)) 'compile-file) f #:to 'value)))) +(define (not-inner-lang? str) + (not ((@ (ice-9 regex) string-match) + (string-append + "glil|glil\\.scm|assembly|assembly\\.scm|bytecode|objcode\\.scm" + "|objcode|tree-il|tree-il\\.scm|value|\\.\\.|\\.") + str))) + +(define (list-languages select) + (let lp((rest (map (lambda (x) (string-append x "/language")) %load-path)) + (result '())) + (cond + ((null? rest) (apply (@ (srfi srfi-1) lset-union) string=? result)) + (else + (let ((ll ((@ (ice-9 ftw) scandir) (car rest) select))) + (lp (cdr rest) (if ll (cons ll result) result))))))) + (define* (compile-shell-switches args #:optional (usage-name "guile")) (let ((arg0 "guile") (script-cell #f) @@ -306,6 +323,12 @@ If FILE begins with `-' the -s switch is mandatory. (cons `(current-language ',(string->symbol (car args))) out))) + ((string=? "--list-languages" arg) ; list all languages + (for-each (lambda (l) + (format #t "~a~%" l)) + (list-languages not-inner-lang?)) + (exit 0)) + ((string=? arg "-ds") ; do script here ;; We put a dummy "load" expression, and let the -s put the ;; filename in. diff --git a/module/scripts/compile.scm b/module/scripts/compile.scm index 20db944..2b94bf9 100644 --- a/module/scripts/compile.scm +++ b/module/scripts/compile.scm @@ -45,6 +45,11 @@ (format (current-error-port) "error: ~{~a~}~%" messages) (exit 1)) +(define (valid-lang? str) + (not ((@ (ice-9 regex) string-match) + "[A-Za-z0-9_ -]+\\.scm|\\.\\.|\\." + str))) + (define %options ;; Specifications of the command-line options. (list (option '(#\h "help") #f #f @@ -80,6 +85,13 @@ (option '(#\O "optimize") #f #f (lambda (opt name arg result) (alist-cons 'optimize? #t result))) + (option '("list-languages") #f #f + (lambda (opt name arg result) + (for-each (lambda (l) + (format #t "~a~%" l)) + ((@@ (ice-9 command-line) list-languages) + valid-lang?)) + (exit 0))) (option '(#\f "from") #t #f (lambda (opt name arg result) (if (assoc-ref result 'from) @@ -157,6 +169,7 @@ Compile each Guile source file FILE into a Guile object. -W, --warn=WARNING emit warnings of type WARNING; use `--warn=help' for a list of available warnings + --list-languages list all available languages -f, --from=LANG specify a source language other than `scheme' -t, --to=LANG specify a target language other than `objcode' -T, --target=TRIPLET produce bytecode for host TRIPLET -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 16:46 ` Nala Ginrut @ 2013-01-31 10:32 ` Andy Wingo 2013-02-01 2:34 ` Nala Ginrut 0 siblings, 1 reply; 12+ messages in thread From: Andy Wingo @ 2013-01-31 10:32 UTC (permalink / raw) To: Nala Ginrut; +Cc: guile-devel Hi :) On Fri 25 Jan 2013 17:46, Nala Ginrut <nalaginrut@gmail.com> writes: > Users just need a way to know what languages could be specified to > --language option. Can you update the patch to use the language-for-humans? accesor that Mark pushed recently? > From a6b321e51a19d3726620a68f8db4902877872460 Mon Sep 17 00:00:00 2001 > From: Nala Ginrut <nalaginrut@gmail.com> > Date: Fri, 25 Jan 2013 18:38:22 +0800 > Subject: [PATCH] List all available languages. > > * ice-9/command-line.scm: list available languages for 'guile' cmd. > > * scripts/compile.scm: list all available languages for 'guild compile' cmd. > > * NOTE: 'guile --list-languages' won't list inner languages, but 'guild compile -l' > will do that. It's cool to add notes, but don't prefix it with a `*' as if "NOTE" were a file name :) Also please wrap messages to 72 characters. > +(define (list-languages select) > + (let lp((rest (map (lambda (x) (string-append x "/language")) %load-path)) > + (result '())) > + (cond > + ((null? rest) (apply (@ (srfi srfi-1) lset-union) string=? result)) > + (else > + (let ((ll ((@ (ice-9 ftw) scandir) (car rest) select))) > + (lp (cdr rest) (if ll (cons ll result) result))))))) > + This helper should go in (system base language), I think. > (define* (compile-shell-switches args #:optional (usage-name "guile")) > (let ((arg0 "guile") > (script-cell #f) > @@ -306,6 +323,12 @@ If FILE begins with `-' the -s switch is mandatory. > (cons `(current-language ',(string->symbol (car args))) > out))) > > + ((string=? "--list-languages" arg) ; list all languages > + (for-each (lambda (l) > + (format #t "~a~%" l)) > + (list-languages not-inner-lang?)) > + (exit 0)) > + > ((string=? arg "-ds") ; do script here > ;; We put a dummy "load" expression, and let the -s put the > ;; filename in. Do we need a command-line argument or should the languages just appear in the --help ? I would think that appearing in the help would be sufficient, no? > @@ -157,6 +169,7 @@ Compile each Guile source file FILE into a Guile object. > -W, --warn=WARNING emit warnings of type WARNING; use `--warn=help' > for a list of available warnings > > + --list-languages list all available languages > -f, --from=LANG specify a source language other than `scheme' > -t, --to=LANG specify a target language other than `objcode' > -T, --target=TRIPLET produce bytecode for host TRIPLET Likewise here. Sorry to be picky, but this adds interface to the Guile main program and is run whenever Guile is run, so we need to be really careful. Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-31 10:32 ` Andy Wingo @ 2013-02-01 2:34 ` Nala Ginrut 0 siblings, 0 replies; 12+ messages in thread From: Nala Ginrut @ 2013-02-01 2:34 UTC (permalink / raw) To: Andy Wingo; +Cc: guile-devel On Thu, 2013-01-31 at 11:32 +0100, Andy Wingo wrote: > Hi :) > > On Fri 25 Jan 2013 17:46, Nala Ginrut <nalaginrut@gmail.com> writes: > > > Users just need a way to know what languages could be specified to > > --language option. > > Can you update the patch to use the language-for-humans? accesor that > Mark pushed recently? > I talked to mark and I think I get the point of your suggestion now(hmm...maybe), I'll update it soon. > > From a6b321e51a19d3726620a68f8db4902877872460 Mon Sep 17 00:00:00 2001 > > From: Nala Ginrut <nalaginrut@gmail.com> > > Date: Fri, 25 Jan 2013 18:38:22 +0800 > > Subject: [PATCH] List all available languages. > > > > * ice-9/command-line.scm: list available languages for 'guile' cmd. > > > > * scripts/compile.scm: list all available languages for 'guild compile' cmd. > > > > * NOTE: 'guile --list-languages' won't list inner languages, but 'guild compile -l' > > will do that. > > It's cool to add notes, but don't prefix it with a `*' as if "NOTE" were > a file name :) Also please wrap messages to 72 characters. > oops ;-) > > +(define (list-languages select) > > + (let lp((rest (map (lambda (x) (string-append x "/language")) %load-path)) > > + (result '())) > > + (cond > > + ((null? rest) (apply (@ (srfi srfi-1) lset-union) string=? result)) > > + (else > > + (let ((ll ((@ (ice-9 ftw) scandir) (car rest) select))) > > + (lp (cdr rest) (if ll (cons ll result) result))))))) > > + > > This helper should go in (system base language), I think. > yeah~ > > (define* (compile-shell-switches args #:optional (usage-name "guile")) > > (let ((arg0 "guile") > > (script-cell #f) > > @@ -306,6 +323,12 @@ If FILE begins with `-' the -s switch is mandatory. > > (cons `(current-language ',(string->symbol (car args))) > > out))) > > > > + ((string=? "--list-languages" arg) ; list all languages > > + (for-each (lambda (l) > > + (format #t "~a~%" l)) > > + (list-languages not-inner-lang?)) > > + (exit 0)) > > + > > ((string=? arg "-ds") ; do script here > > ;; We put a dummy "load" expression, and let the -s put the > > ;; filename in. > > Do we need a command-line argument or should the languages just appear > in the --help ? I would think that appearing in the help would be > sufficient, no? > My original thought was list them when --help runs, but I realized that we have guildhall, folks may add many new external language-frontend(they don't have to be added in Guile itself), so the --help shows maybe ugly. That's why I added --list-languages. WDYT? > > @@ -157,6 +169,7 @@ Compile each Guile source file FILE into a Guile object. > > -W, --warn=WARNING emit warnings of type WARNING; use `--warn=help' > > for a list of available warnings > > > > + --list-languages list all available languages > > -f, --from=LANG specify a source language other than `scheme' > > -t, --to=LANG specify a target language other than `objcode' > > -T, --target=TRIPLET produce bytecode for host TRIPLET > > Likewise here. > > Sorry to be picky, but this adds interface to the Guile main program and > is run whenever Guile is run, so we need to be really careful. > > Andy ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 11:06 ` Andy Wingo 2013-01-25 16:46 ` Nala Ginrut @ 2013-01-25 20:06 ` Mark H Weaver 2013-01-25 22:50 ` Mark H Weaver 1 sibling, 1 reply; 12+ messages in thread From: Mark H Weaver @ 2013-01-25 20:06 UTC (permalink / raw) To: Andy Wingo; +Cc: guile-devel Hi Andy, Andy Wingo <wingo@pobox.com> writes: > [...] 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. I'm not sure this is a good approach. What if someone adds a language that compiles to Scheme? How about adding a new boolean field to <language> that marks it as "internal" or something to that effect? We could have it default to #f for backward compatibility, and mark our internal languages as #t. What do you think? Mark ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 20:06 ` Mark H Weaver @ 2013-01-25 22:50 ` Mark H Weaver 2013-01-26 1:44 ` Nala Ginrut 2013-01-27 10:21 ` Andy Wingo 0 siblings, 2 replies; 12+ messages in thread From: Mark H Weaver @ 2013-01-25 22:50 UTC (permalink / raw) To: Andy Wingo; +Cc: guile-devel [-- Attachment #1: Type: text/plain, Size: 296 bytes --] I wrote: > How about adding a new boolean field to <language> that marks it as > "internal" or something to that effect? We could have it default to #f > for backward compatibility, and mark our internal languages as #t. I've attached a proposed patch to add this field. Thoughts? Mark [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: [PATCH] Add 'internal-only?' flag to <language> specifications --] [-- Type: text/x-diff, Size: 4696 bytes --] From 605cbde174afa52d4ccfd8528ef6903ad98a8002 Mon Sep 17 00:00:00 2001 From: Mark H Weaver <mhw@netris.org> Date: Fri, 25 Jan 2013 17:44:14 -0500 Subject: [PATCH] Add 'internal-only?' flag to <language> specifications. * module/system/base/language.scm (<language>): Add 'internal-only?' field, and export new 'language-internal-only?' predicate. * doc/ref/compiler.texi (Compiler Tower): Document. * module/language/assembly/spec.scm, module/language/bytecode/spec.scm, module/language/glil/spec.scm, module/language/objcode/spec.scm, module/language/tree-il/spec.scm, module/language/value/spec.scm: Mark these languages as 'internal-only?'. --- doc/ref/compiler.texi | 3 ++- module/language/assembly/spec.scm | 1 + module/language/bytecode/spec.scm | 1 + module/language/glil/spec.scm | 4 +++- module/language/objcode/spec.scm | 1 + module/language/tree-il/spec.scm | 1 + module/language/value/spec.scm | 1 + module/system/base/language.scm | 4 +++- 8 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/ref/compiler.texi b/doc/ref/compiler.texi index a88942d..46cde8c 100644 --- a/doc/ref/compiler.texi +++ b/doc/ref/compiler.texi @@ -55,7 +55,8 @@ They are registered with the @code{define-language} form. @deffn {Scheme Syntax} define-language @ name title reader printer @ [parser=#f] [compilers='()] [decompilers='()] [evaluator=#f] @ -[joiner=#f] [make-default-environment=make-fresh-user-module] +[joiner=#f] [internal-only?=#f] @ +[make-default-environment=make-fresh-user-module] Define a language. This syntax defines a @code{#<language>} object, bound to @var{name} diff --git a/module/language/assembly/spec.scm b/module/language/assembly/spec.scm index 01a55c4..a5efcb7 100644 --- a/module/language/assembly/spec.scm +++ b/module/language/assembly/spec.scm @@ -31,4 +31,5 @@ #:parser read ;; fixme: make a verifier? #:compilers `((bytecode . ,compile-bytecode)) #:decompilers `((bytecode . ,decompile-bytecode)) + #:internal-only? #t ) diff --git a/module/language/bytecode/spec.scm b/module/language/bytecode/spec.scm index 57ccd71..af2f9c7 100644 --- a/module/language/bytecode/spec.scm +++ b/module/language/bytecode/spec.scm @@ -35,4 +35,5 @@ #:printer write #:compilers `((objcode . ,compile-objcode)) #:decompilers `((objcode . ,decompile-objcode)) + #:internal-only? #t ) diff --git a/module/language/glil/spec.scm b/module/language/glil/spec.scm index a8164e5..3faa9b9 100644 --- a/module/language/glil/spec.scm +++ b/module/language/glil/spec.scm @@ -37,4 +37,6 @@ #:printer write-glil #:parser parse-glil #:compilers `((assembly . ,compile-asm)) - #:decompilers `((assembly . ,decompile-assembly))) + #:decompilers `((assembly . ,decompile-assembly)) + #:internal-only? #t + ) diff --git a/module/language/objcode/spec.scm b/module/language/objcode/spec.scm index 7cc85b7..a17166a 100644 --- a/module/language/objcode/spec.scm +++ b/module/language/objcode/spec.scm @@ -79,4 +79,5 @@ #:printer write-objcode #:compilers `((value . ,objcode->value)) #:decompilers `((value . ,decompile-value)) + #:internal-only? #t ) diff --git a/module/language/tree-il/spec.scm b/module/language/tree-il/spec.scm index 38e6d31..eae93b6 100644 --- a/module/language/tree-il/spec.scm +++ b/module/language/tree-il/spec.scm @@ -42,4 +42,5 @@ #:parser parse-tree-il #:joiner join #:compilers `((glil . ,compile-glil)) + #:internal-only? #t ) diff --git a/module/language/value/spec.scm b/module/language/value/spec.scm index 6c6cff9..26823ca 100644 --- a/module/language/value/spec.scm +++ b/module/language/value/spec.scm @@ -26,4 +26,5 @@ #:title "Values" #:reader #f #:printer write + #:internal-only? #t ) diff --git a/module/system/base/language.scm b/module/system/base/language.scm index 81b43b7..8949c05 100644 --- a/module/system/base/language.scm +++ b/module/system/base/language.scm @@ -25,7 +25,8 @@ language-name language-title language-reader language-printer language-parser language-compilers language-decompilers language-evaluator - language-joiner language-make-default-environment + language-joiner language-internal-only? + language-make-default-environment lookup-compilation-order lookup-decompilation-order invalidate-compilation-cache! default-environment @@ -49,6 +50,7 @@ (decompilers '()) (evaluator #f) (joiner #f) + (internal-only? #f) (make-default-environment make-fresh-user-module)) (define-macro (define-language name . spec) -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 22:50 ` Mark H Weaver @ 2013-01-26 1:44 ` Nala Ginrut 2013-01-27 10:21 ` Andy Wingo 1 sibling, 0 replies; 12+ messages in thread From: Nala Ginrut @ 2013-01-26 1:44 UTC (permalink / raw) To: Mark H Weaver; +Cc: Andy Wingo, guile-devel On Fri, 2013-01-25 at 17:50 -0500, Mark H Weaver wrote: > I wrote: > > How about adding a new boolean field to <language> that marks it as > > "internal" or something to that effect? We could have it default to #f > > for backward compatibility, and mark our internal languages as #t. > > I've attached a proposed patch to add this field. Thoughts? > > Mark > OK, I see. How about printing like this: -------------"guild compile --list-languages"------------------ Front-end | Inner Language scheme ecmascript elisp => tree-il => glil => assembly => bytecode => value lua ruby ... --------------------------end---------------------------------- It's no need to print like this in 'guile --list-languages'. Thanks! > > differences between files attachment > (0001-Add-internal-only-flag-to-language-specifications.patch), > "[PATCH] Add 'internal-only?' flag to <language> specifications" > From 605cbde174afa52d4ccfd8528ef6903ad98a8002 Mon Sep 17 00:00:00 2001 > From: Mark H Weaver <mhw@netris.org> > Date: Fri, 25 Jan 2013 17:44:14 -0500 > Subject: [PATCH] Add 'internal-only?' flag to <language> specifications. > > * module/system/base/language.scm (<language>): Add 'internal-only?' > field, and export new 'language-internal-only?' predicate. > > * doc/ref/compiler.texi (Compiler Tower): Document. > > * module/language/assembly/spec.scm, module/language/bytecode/spec.scm, > module/language/glil/spec.scm, module/language/objcode/spec.scm, > module/language/tree-il/spec.scm, module/language/value/spec.scm: > Mark these languages as 'internal-only?'. > --- > doc/ref/compiler.texi | 3 ++- > module/language/assembly/spec.scm | 1 + > module/language/bytecode/spec.scm | 1 + > module/language/glil/spec.scm | 4 +++- > module/language/objcode/spec.scm | 1 + > module/language/tree-il/spec.scm | 1 + > module/language/value/spec.scm | 1 + > module/system/base/language.scm | 4 +++- > 8 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/doc/ref/compiler.texi b/doc/ref/compiler.texi > index a88942d..46cde8c 100644 > --- a/doc/ref/compiler.texi > +++ b/doc/ref/compiler.texi > @@ -55,7 +55,8 @@ They are registered with the @code{define-language} form. > @deffn {Scheme Syntax} define-language @ > name title reader printer @ > [parser=#f] [compilers='()] [decompilers='()] [evaluator=#f] @ > -[joiner=#f] [make-default-environment=make-fresh-user-module] > +[joiner=#f] [internal-only?=#f] @ > +[make-default-environment=make-fresh-user-module] > Define a language. > > This syntax defines a @code{#<language>} object, bound to @var{name} > diff --git a/module/language/assembly/spec.scm b/module/language/assembly/spec.scm > index 01a55c4..a5efcb7 100644 > --- a/module/language/assembly/spec.scm > +++ b/module/language/assembly/spec.scm > @@ -31,4 +31,5 @@ > #:parser read ;; fixme: make a verifier? > #:compilers `((bytecode . ,compile-bytecode)) > #:decompilers `((bytecode . ,decompile-bytecode)) > + #:internal-only? #t > ) > diff --git a/module/language/bytecode/spec.scm b/module/language/bytecode/spec.scm > index 57ccd71..af2f9c7 100644 > --- a/module/language/bytecode/spec.scm > +++ b/module/language/bytecode/spec.scm > @@ -35,4 +35,5 @@ > #:printer write > #:compilers `((objcode . ,compile-objcode)) > #:decompilers `((objcode . ,decompile-objcode)) > + #:internal-only? #t > ) > diff --git a/module/language/glil/spec.scm b/module/language/glil/spec.scm > index a8164e5..3faa9b9 100644 > --- a/module/language/glil/spec.scm > +++ b/module/language/glil/spec.scm > @@ -37,4 +37,6 @@ > #:printer write-glil > #:parser parse-glil > #:compilers `((assembly . ,compile-asm)) > - #:decompilers `((assembly . ,decompile-assembly))) > + #:decompilers `((assembly . ,decompile-assembly)) > + #:internal-only? #t > + ) > diff --git a/module/language/objcode/spec.scm b/module/language/objcode/spec.scm > index 7cc85b7..a17166a 100644 > --- a/module/language/objcode/spec.scm > +++ b/module/language/objcode/spec.scm > @@ -79,4 +79,5 @@ > #:printer write-objcode > #:compilers `((value . ,objcode->value)) > #:decompilers `((value . ,decompile-value)) > + #:internal-only? #t > ) > diff --git a/module/language/tree-il/spec.scm b/module/language/tree-il/spec.scm > index 38e6d31..eae93b6 100644 > --- a/module/language/tree-il/spec.scm > +++ b/module/language/tree-il/spec.scm > @@ -42,4 +42,5 @@ > #:parser parse-tree-il > #:joiner join > #:compilers `((glil . ,compile-glil)) > + #:internal-only? #t > ) > diff --git a/module/language/value/spec.scm b/module/language/value/spec.scm > index 6c6cff9..26823ca 100644 > --- a/module/language/value/spec.scm > +++ b/module/language/value/spec.scm > @@ -26,4 +26,5 @@ > #:title "Values" > #:reader #f > #:printer write > + #:internal-only? #t > ) > diff --git a/module/system/base/language.scm b/module/system/base/language.scm > index 81b43b7..8949c05 100644 > --- a/module/system/base/language.scm > +++ b/module/system/base/language.scm > @@ -25,7 +25,8 @@ > language-name language-title language-reader > language-printer language-parser > language-compilers language-decompilers language-evaluator > - language-joiner language-make-default-environment > + language-joiner language-internal-only? > + language-make-default-environment > > lookup-compilation-order lookup-decompilation-order > invalidate-compilation-cache! default-environment > @@ -49,6 +50,7 @@ > (decompilers '()) > (evaluator #f) > (joiner #f) > + (internal-only? #f) > (make-default-environment make-fresh-user-module)) > > (define-macro (define-language name . spec) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-25 22:50 ` Mark H Weaver 2013-01-26 1:44 ` Nala Ginrut @ 2013-01-27 10:21 ` Andy Wingo 2013-01-27 15:31 ` Mark H Weaver 1 sibling, 1 reply; 12+ messages in thread From: Andy Wingo @ 2013-01-27 10:21 UTC (permalink / raw) To: Mark H Weaver; +Cc: guile-devel On Fri 25 Jan 2013 23:50, Mark H Weaver <mhw@netris.org> writes: > I wrote: >> How about adding a new boolean field to <language> that marks it as >> "internal" or something to that effect? We could have it default to #f >> for backward compatibility, and mark our internal languages as #t. > > I've attached a proposed patch to add this field. Thoughts? LGTM, though I would call it something else -- because these languages are internal but not internal only. Other possibilities: "internal", "for-humans", ... Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FEATURE] List all available languages 2013-01-27 10:21 ` Andy Wingo @ 2013-01-27 15:31 ` Mark H Weaver 0 siblings, 0 replies; 12+ messages in thread From: Mark H Weaver @ 2013-01-27 15:31 UTC (permalink / raw) To: Andy Wingo; +Cc: guile-devel Andy Wingo <wingo@pobox.com> writes: > On Fri 25 Jan 2013 23:50, Mark H Weaver <mhw@netris.org> writes: >> I've attached a proposed patch to add this field. Thoughts? > > LGTM, though I would call it something else -- because these languages > are internal but not internal only. Other possibilities: "internal", > "for-humans", ... Oooh, I like "for-humans?". I pushed it to stable-2.0. Thanks! Mark ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-02-01 2:34 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-01-23 11:28 [FEATURE] List all available languages Nala Ginrut 2013-01-25 9:56 ` Nala Ginrut 2013-01-25 10:43 ` Nala Ginrut 2013-01-25 11:06 ` Andy Wingo 2013-01-25 16:46 ` Nala Ginrut 2013-01-31 10:32 ` Andy Wingo 2013-02-01 2:34 ` Nala Ginrut 2013-01-25 20:06 ` Mark H Weaver 2013-01-25 22:50 ` Mark H Weaver 2013-01-26 1:44 ` Nala Ginrut 2013-01-27 10:21 ` Andy Wingo 2013-01-27 15:31 ` Mark H Weaver
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).