unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Steve Juranich <sjuranic@gmail.com>
Subject: Using a macro with FOLD alters FOLD procedure!
Date: Fri, 15 Apr 2005 11:38:11 -0700	[thread overview]
Message-ID: <56190b6c05041511382ae259d@mail.gmail.com> (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

             reply	other threads:[~2005-04-15 18:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-15 18:38 Steve Juranich [this message]
2005-04-15 19:50 ` Using a macro with FOLD alters FOLD procedure! 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56190b6c05041511382ae259d@mail.gmail.com \
    --to=sjuranic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).