From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: [FEATURE] List all available languages Date: Fri, 25 Jan 2013 12:06:21 +0100 Message-ID: <878v7hcyj6.fsf@pobox.com> References: <1358940518.3676.5.camel@Renee-desktop.suse> <1359107760.3676.28.camel@Renee-desktop.suse> <1359110632.3676.30.camel@Renee-desktop.suse> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1359111995 26070 80.91.229.3 (25 Jan 2013 11:06:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Jan 2013 11:06:35 +0000 (UTC) Cc: guile-devel@gnu.org To: Nala Ginrut Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 25 12:06:51 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tyh7Q-00028F-5u for guile-devel@m.gmane.org; Fri, 25 Jan 2013 12:06:48 +0100 Original-Received: from localhost ([::1]:58585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyh78-0006iF-M7 for guile-devel@m.gmane.org; Fri, 25 Jan 2013 06:06:30 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyh75-0006hl-2W for guile-devel@gnu.org; Fri, 25 Jan 2013 06:06:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tyh73-0007vH-OL for guile-devel@gnu.org; Fri, 25 Jan 2013 06:06:26 -0500 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:41905 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyh73-0007v9-KG for guile-devel@gnu.org; Fri, 25 Jan 2013 06:06:25 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id F0708A40F; Fri, 25 Jan 2013 06:06:24 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=Sj1zMhVqlzmw+XvbZRCazPXO1sk=; b=G9N2xi dkNaK+2TQJrEw1Bu7hc986SXuwwJx9Bn/BjGt3mztXNRTzmkGOAFtClwgjidx//B MbFOKONdt5CT2UteryWgKBUXHq1tEg3eBjTv9nfxO27Q+k9pMSDkmdwcVJ8/KBm9 P74t8yt6oJH90Hh8ZTFQD73CAuU5lRyRHYoCA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=Ju9P2gIWbV6QtbSIjXFXKtAoIgwS2H5W 2xVDhUJpe383ZT2UQqpadkygxWWl8eDCrOOPkq+AdHoEJ4ktazccKH1IdulmCTe3 91ml2/ve9wYvvrVnSJw2kmSHbxiUnk8ecTy12dsHzhIFGEwV2svvOt4eQ/9OMcQ2 +WYWptLK2J0= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id E735CA40E; Fri, 25 Jan 2013 06:06:24 -0500 (EST) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 51551A40D; Fri, 25 Jan 2013 06:06:24 -0500 (EST) In-Reply-To: <1359110632.3676.30.camel@Renee-desktop.suse> (Nala Ginrut's message of "Fri, 25 Jan 2013 18:43:52 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-Pobox-Relay-ID: 41F37C74-66DF-11E2-B903-0A4F0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15590 Archived-At: On Fri 25 Jan 2013 11:43, Nala Ginrut 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/