From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Daniel Skarda <0rfelyus@ucw.cz> Newsgroups: gmane.lisp.guile.devel Subject: Re: Adding stuff to the core distro (was Re: Infix syntax) Date: 16 Oct 2002 23:35:15 +0200 Sender: guile-devel-admin@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1034989845 4104 80.91.224.249 (19 Oct 2002 01:10:45 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 19 Oct 2002 01:10:45 +0000 (UTC) Cc: guile-devel@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 182i8Z-00013v-00 for ; Sat, 19 Oct 2002 03:10:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 182i9H-0007BA-00; Fri, 18 Oct 2002 21:11:27 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 182i7m-0006iT-00 for guile-devel@gnu.org; Fri, 18 Oct 2002 21:09:54 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 182i7j-0006h1-00 for guile-devel@gnu.org; Fri, 18 Oct 2002 21:09:53 -0400 Original-Received: from gnudist.gnu.org ([199.232.41.7]) by monty-python.gnu.org with esmtp (Exim 4.10) id 182bkL-000879-01 for guile-devel@gnu.org; Fri, 18 Oct 2002 14:21:17 -0400 Original-Received: from stateless1.tiscali.cz ([213.235.135.70] helo=mail.tiscali.cz) by gnudist.gnu.org with esmtp (Exim 4.10) id 1820lc-0006KO-00 for guile-devel@gnu.org; Wed, 16 Oct 2002 22:52:08 -0400 Original-Received: from hobitin.ucw.cz (212.11.106.92) by mail.tiscali.cz (6.0.044) id 3DA29C7F00179D25; Thu, 17 Oct 2002 04:46:46 +0200 Original-Received: from 0rfelyus by hobitin.ucw.cz with local (Exim 3.36 #1 (Debian)) id 181vox-0000H6-00; Wed, 16 Oct 2002 23:35:15 +0200 Original-To: Neil Jerram In-Reply-To: Original-Lines: 50 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:1563 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1563 > BTW, does (ice-9 infix) handle tricky whitespace like in `#[2+4* 8]'? > If not, you could use a simple macro rather than a read hash > extension: `(infix 2 + 4 * 8)' rather than `#[2 + 4 * 8]'. As a > macro, `infix' would obey the usual module rules. Wow, that's clever. It seems I played with read hash extension too much that I have not noticed simpler (and schemish) way... (On the other hand, #[] is shorter :-) Current infix module is divided to tokenizer (an arbitrary function without any parameter, that returns new token) and parser (read-infix-expr tokenizer ....) There is also function make-read-tokenizer, that can build tokenizer for particular port. This tokenizer uses combination of read-char/read, it also splits symbols, when there is #\[ #\] or #\, inside them. No other tricky whitespace handling is performed (it would be dangerous, since #\- and #\* are often used in scheme symbols). infix.scm proposal, second edition: ------------------------------------- (define-infix-macro NAME) define macro `NAME' which transforms infix syntax to scheme expressions. It also defines variables *NAME-infix*, *NAME-prefix* hash tables (or rather alists?) and *NAME-split-list*. NAME splits its arguments according characters in *NAME-split-list* list and creates tokenizer, which successively feeds read-infix-expr with tokens. (add-infix-operator NAME operator func paramers ...) (add-prefix-operator NAME operator func paramers ...) (add-infix-separator NAME character) I think that "clever" whitespace handling would be sometimes very confusing. It is possible to split 4*8, but #\- will cause nightmare (foo-bar). IMHO it would not be wise to split using symbol lookup (defined?) since it could cause mysterious bugs ... I am going to rewrite infix.scm as soon as I get some spare time (first I should stop spamming guile-devel with long emails, I guess :) 0. ps: Sometimes I also use read-hash extension for shorter (sed|awk|perl|...)-like regular expressions: #/foo.*bar/i, sometimes I also use srfi-10 #,(rx "foo.*bar" icase). Do you think that other guilers would benefit from such hairy extensions? I try to clean up my regexps.scm and post it later. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel