I've noticed some strange behavior from (srfi-1) "fold" using a macro
as the KONS argument.

I've attached a file that exhibits the problem.  In a nutshell, using
a macro as the KONS argument for FOLD results in the procedure source
for FOLD being altered.

I was wondering, is this "expected behavior", or have I uncovered
something?  If this is expected behavior, I'd suggest that FOLD should
do a check to make sure that the KONS argument is not a macro.  If
I've uncovered a bug, I'll file a bug report.
-- 
Steve Juranich
Tucson, AZ
USA
#! /bin/bash
exec guile -s "$0"
!#

(use-modules (ice-9 pretty-print)
	     (srfi srfi-1))

;;; First, show that "fold" is in a good state (cf. srfi/srfi-1.scm).
(display "Original source for FOLD:\n")
(pretty-print (procedure-source fold))
(display "\n\n")

;;; Run "fold" with "+" as the KONS.
(fold + 0 '(1 2 3 4 5))

;;; Show that the source has NOT been altered (substantially)
(display "(More or less) Unaltered source for FOLD:\n")
(pretty-print (procedure-source fold))
(display "\n\n")

;;; Run "fold" with a macro as the KONS argument.
(define-macro (++ a b) `(+ ,a ,b))
(fold ++ 0 '(1 2 3 4 5))

(display "Altered (broken) source for FOLD:\n")
(pretty-print (procedure-source fold))
(display "\n\n")

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

Reply via email to