GNU bug report logs - #14859
my-or macro in documentation

Previous Next

Package: guile;

Reported by: Josep Portella Florit <jpf <at> primfilat.com>

Date: Sat, 13 Jul 2013 19:12:01 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Josep Portella Florit <jpf <at> primfilat.com>
To: 14859 <at> debbugs.gnu.org
Subject: bug#14859: my-or macro in documentation
Date: Sat, 13 Jul 2013 20:52:45 +0200
Hi!

The my-or example macro in the documentation has a subtle bug.

          (letrec-syntax ((my-or
                           (syntax-rules ()
                             ((my-or)
                              #t)
                             ((my-or exp)
                              exp)
                             ((my-or exp rest ...)
                              (let ((t exp))
                                (if exp
                                    exp
                                    (my-or rest ...)))))))
            (my-or #f "rockaway beach"))

In the third rule t is bound to exp, presumably to use t instead of exp
to prevent evaluating exp multiple times, but t is never used and exp is
used again.  This is the bug in action:

scheme@(guile-user)> (letrec-syntax ((my-or
                           (syntax-rules ()
                             ((my-or)
                              #t)
                             ((my-or exp)
                              exp)
                             ((my-or exp rest ...)
                              (let ((t exp))
                                (if exp
                                    exp
                                    (my-or rest ...)))))))
            (my-or (display "*") 1))
***scheme@(guile-user)>

I'm sure you already know how to fix it :-)

          (letrec-syntax ((my-or
                           (syntax-rules ()
                             ((my-or)
                              #t)
                             ((my-or exp)
                              exp)
                             ((my-or exp rest ...)
                              (let ((t exp))
                                (if t
                                    t
                                    (my-or rest ...)))))))
            (my-or #f "rockaway beach"))

Josep




This bug report was last modified 12 years and 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.