unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Using a macro with FOLD alters FOLD procedure!
@ 2005-04-15 18:38 Steve Juranich
  2005-04-15 19:50 ` Stephen Compall
  0 siblings, 1 reply; 9+ messages in thread
From: Steve Juranich @ 2005-04-15 18:38 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

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

[-- Attachment #2: exhibit-bug.scm --]
[-- Type: text/x-scheme, Size: 712 bytes --]

#! /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")


[-- Attachment #3: Type: text/plain, Size: 140 bytes --]

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

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

end of thread, other threads:[~2005-04-23 20:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-15 18:38 Using a macro with FOLD alters FOLD procedure! Steve Juranich
2005-04-15 19:50 ` Stephen Compall
2005-04-15 22:20   ` Steve Juranich
2005-04-16 11:46     ` Neil Jerram
2005-04-18  0:45       ` Rob Browning
2005-04-21  6:35         ` Neil Jerram
2005-04-21 22:16           ` Kevin Ryde
2005-04-22  8:27             ` Andy Wingo
2005-04-23 20:18             ` Neil Jerram

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