unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* srfi-26 (cut, cute)
@ 2002-10-03 20:45 Daniel Skarda
  2002-10-05  8:55 ` Neil Jerram
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Skarda @ 2002-10-03 20:45 UTC (permalink / raw)


Hello,

  during summer I browsed through srfi specification and as an excercice 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: srfi-26 (cut, cute)
  2002-10-03 20:45 srfi-26 (cut, cute) Daniel Skarda
@ 2002-10-05  8:55 ` Neil Jerram
  2002-10-05 20:15   ` Rob Browning
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Jerram @ 2002-10-05  8:55 UTC (permalink / raw)
  Cc: guile-devel, guile-user

>>>>> "Daniel" == Daniel Skarda <0rfelyus@ucw.cz> writes:

    Daniel> Hello, during summer I browsed through srfi specification
    Daniel> and as an excercice I implemented srfi-26
    Daniel> (curry-which-is-not-curry :-). I hope somebody with write
    Daniel> access to CVS will like it and commit it.

Looks good to me; I'll commit tomorrow unless anyone objects.  Have
you signed assignment and disclaimer papers to cover this?

        Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: srfi-26 (cut, cute)
  2002-10-05  8:55 ` Neil Jerram
@ 2002-10-05 20:15   ` Rob Browning
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Browning @ 2002-10-05 20:15 UTC (permalink / raw)
  Cc: Daniel Skarda, guile-devel, guile-user

Neil Jerram <neil@ossau.uklinux.net> writes:

> Looks good to me; I'll commit tomorrow unless anyone objects.  Have
> you signed assignment and disclaimer papers to cover this?

I'd suggest we not put it in ice-9 for now, though.  As a general
rule, I think we'd be better off moving in the direction of a smaller
base.

(ohh, and this reminds me -- we still need to fix gensym...)

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-05 20:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-03 20:45 srfi-26 (cut, cute) Daniel Skarda
2002-10-05  8:55 ` Neil Jerram
2002-10-05 20:15   ` Rob Browning

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).