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: srfi-26 Date: Thu, 15 Jan 2004 10:36:45 +0100 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <878ykauf96.wl@strelka.synthcode.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1074166354 2737 80.91.224.253 (15 Jan 2004 11:32:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 15 Jan 2004 11:32:34 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jan 15 12:32:27 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ah5jf-0000xT-00 for ; Thu, 15 Jan 2004 12:32:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ah5eV-0000uU-KZ for guile-devel@m.gmane.org; Thu, 15 Jan 2004 06:27:07 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1Ah5da-0000XU-Gb for guile-devel@gnu.org; Thu, 15 Jan 2004 06:26:10 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1Ah5cl-0008WT-0w for guile-devel@gnu.org; Thu, 15 Jan 2004 06:25:51 -0500 Original-Received: from [130.244.199.129] (helo=fep01-svc.swip.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ah5ck-0008Vn-2I for guile-devel@gnu.org; Thu, 15 Jan 2004 06:25:18 -0500 Original-Received: from localhost ([213.102.39.135]) by fep01-svc.swip.net with ESMTP id <20040115112516.JSHY3280.fep01-svc.swip.net@localhost>; Thu, 15 Jan 2004 12:25:16 +0100 Original-Received: from 0rfelyus by localhost with local (Exim 3.36 #1 (Debian)) id 1Ah3vi-00023a-00; Thu, 15 Jan 2004 10:36:46 +0100 Original-To: Alex Shinn In-Reply-To: <878ykauf96.wl@strelka.synthcode.com> (Alex Shinn's message of "Thu, 15 Jan 2004 11:17:41 +0900") User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 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 Xref: main.gmane.org gmane.lisp.guile.devel:3217 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3217 Hello, srfi-26 and cut/cute are indeed cute macros. I sent my implementation to guile-devel about fourteen months ago, but it seems nobody cared to commit it to CVS (so I wish you good luck ;-) 0. From: Daniel Skarda <0rfelyus@ucw.cz> Subject: srfi-26 (cut, cute) To: guile-devel@gnu.org, guile-user@gnu.org Date: 03 Oct 2002 22:45:55 +0200 Hello, during summer I browsed through srfi specification and as an exercise I implemented srfi-26 (curry-which-is-not-curry :-). I hope somebody with write access to CVS will like it and commit it. I found cut and cute macros very handy (they usually safe you a lot of boring typing and screen space :-) so maybe they should be also part of ice-9/boot-9.scm. Have a nice day, 0. ps: The reference implementation uses define-syntax instead of define-macro. I chose define-macro since I prefere this way of writing macros and (use-modules (ice-9 syncase)) doubles guile startup time (at least on my comp). ;--- srfi/srfi-26.scm: ---------------------------------------------------------- (define-macro (cut slot . slots) (let loop ((slots (cons slot slots)) (params '()) (args '())) (if (null? slots) `(lambda ,(reverse! params) ,(reverse! args)) (let ((s (car slots)) (rest (cdr slots))) (case s ((<>) (let ((var (gensym))) (loop rest (cons var params) (cons var args)))) ((<...>) (if (pair? rest) (error "<...> not on the end of cut expression")) (let ((var (gensym))) `(lambda ,(append! (reverse! params) var) (apply ,@(reverse! (cons var args)))))) (else (loop rest params (cons s args)))))))) (define-macro (cute . slots) (let ((temp (map (lambda (s) (and (not (memq s '(<> <...>))) (gensym))) slots))) `(let ,(delq! #f (map (lambda (t s) (and t (list t s))) temp slots)) (cut ,@(map (lambda (t s) (or t s)) temp slots))))) _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel