guile-user
[Top][All Lists]
Advanced

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

Re: and-let* is not composable?


From: Stefan Israelsson Tampe
Subject: Re: and-let* is not composable?
Date: Tue, 10 Sep 2013 15:42:10 +0200

Ahh, I thought we nuked the unhygienic macros in our tool-chain, That is a BUG!

Anyway can I suggest a Bug report where we
1) Make the unhygienic define-macros in the following files hygienic,
-------------------------------------------------
module/srfi/srfi-4.scm:
module/srfi/srfi-69.scm:
module/srfi/srfi-4/gnu.scm:
module/system/base/syntax.scm:
module/system/base/language.scm:
module/system/base/lalr.upstream.scm:
module/statprof.scm:
module/oop/goops.scm:
module/oop/goops/save.scm:
module/oop/goops/accessors.scm:
module/texinfo/plain-text.scm:
module/ice-9/i18n.scm:
module/ice-9/time.scm:
module/ice-9/serialize.scm:
module/ice-9/session.scm:
module/ice-9/optargs.scm:
module/scripts/snarf-check-and-output-texi.scm:
module/scripts/lint.scm:
module/sxml/ssax/input-parse.scm:
module/sxml/transform.scm:
module/sxml/upstream/SXPath-old.scm:
module/sxml/upstream/SSAX.scm:;
module/language/tree-il/primitives.scm:
module/language/ecmascript/base.scm:
module/language/assembly/disassemble.scm:
module/rnrs/bytevectors.scm:

And also change the defmacro forms in,
---------------------------------------------------------
module/system/base/lalr.scm:
module/texinfo/reflection.scm:
module/ice-9/and-let-star.scm:
module/ice-9/calling.scm:
module/ice-9/expect.scm:
module/ice-9/optargs.scm:
module/scripts/generate-autoload.scm:
module/scripts/generate-autoload.scm:

/Stefan




On Mon, Sep 9, 2013 at 11:34 PM, Ian Price <address@hidden> wrote:
Stefan Israelsson Tampe <address@hidden> writes:

> (use-modules (srfi srfi-2))
> (use-modules (srfi srfi-1))
>
> (define-curried (string-matches pattern string)
>    (and-let* ((match-struct (string-match pattern string))
>                  (count (match:count match-struct)))
>       (map (lambda(n)(match:substring match-struct n))
>          (iota (1- count) 1))))
>
> scheme@(guile-user)> (string-matches "([a-z])" "a")
> $4 = ("a")
>
>
> ,exp ((string-matches "([a-z])") "a")
> $5 = ((lambda (string-871)
>    (let ((match-struct-876
>            (string-match "([a-z])" string)))
>      (if match-struct-876
>        (let ((count-880 (match:count match-struct-876)))
>          (if count-880
>            (map (lambda (n-883)
>                   (match:substring match-struct-876 n-883))
>                 (iota (#{1-}# count-880) 1))
>            #f))
>        #f)))
>  "a")
>
> And we see that string is not managed correctly. Is this a bug? I
> can't understand why this is not treated as intended!

The problem is one that occurs when hygienic and non-hygienic macros are
mixed. Here, and-let* is the non-hygienic one. Basically, in a hygienic
macro, you carry around a bunch of context to allow you to refer to the
right variable names. Then defmacro comes along, strips all that away,
and uses the raw symbol names.

We can fix and-let* to be hygienic, that's pretty easy, but I'm not sure
what you can do about this in general. It's not like you can pass in the
gensymed name, because that will break the way people who for some
reason still right defmacros expect them to work.

Dunno, maybe I'm just missing some insight here.

--
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"


reply via email to

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