guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using a macro with FOLD alters FOLD procedure!


From: Steve Juranich
Subject: Re: Using a macro with FOLD alters FOLD procedure!
Date: Fri, 15 Apr 2005 15:20:16 -0700

On 4/15/05, Stephen Compall <address@hidden> wrote:
> `fold' in SRFI-1 mentions that KONS is supposed to be a function.
> 
> If you give a macro to fold, the macro gets expanded and memoized as
> such, when the macro is called normally, as it is as an optimization in
> the common case of one list.  Try passing multiple lists; I bet you will
> get a type error on `apply'.

Thanks for taking the time to reply.  Please understand that I'm not
taking a harsh tone with you at all.  But this "not quite a bug" bit
me very hard and I'm still stinging a little.

I see your point that the documentation mentions that KONS needs to be
a procedure.  But from a user's perspective, I don't think that I
should have to be reading the docs with a lawyer's mindset to avoid
this kind of problem.

Furthermore, the reason I got bit with this was because I was using
REDUCE (an alias for FOLD) with builtin AND as the KONS.  Please
observe:

guile> (fold + 0 '(1 2 3 4 5)) ; works
15
guile> (fold and #t '(#t #t #t)) ; seems okay.
#t
guile> (fold + 0 '(1 2 3 4 5)) ; WTF??
0

It will take a lot of fancy talking and beer to make me believe that
the above is not a demonstration of a bug.  I would strongly disagree
with the SRFI's author's opinion that "there's little point in
requiring these procedures to do more."  In this case, the point would
be to make sure that the user (i.e, me) doesn't render the
painstakingly crafted software completely useless.

> So I would say "it is an error" to pass a macro to fold.  Seems like a
> serious error, of course, that leaves the system in an undefined state
> unlike errors that don't modify the implementation :); I am no authority
> on whether this should be fixed (which is the only issue; the fix is
> trivial, but has potential philosophical implications).

Well, speaking on the authority of being a Guile user, is this the
kind of behavior you want Guile to have?  This is exactly the reason I
left Perl.  There is no good reason to have silently failing software.
 This is even worse, as what has happened is that the implementation
has been silently redefined!!

I think that, at the very least, this is a bug in the documentation. 
There should be all kinds of  flashing red lights and sirens when this
kind of behavior is possible.

-- 
Steve Juranich
Tucson, AZ
USA




reply via email to

[Prev in Thread] Current Thread [Next in Thread]