[plt-scheme] Re: Error in match or error in me?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Mar 17 14:05:39 EDT 2010

Sam and I worked it out on IRC.

Here's a smaller error:

(match (list 'a 'b 'c)
  [(or (list a b)
       (and (app (lambda _ #f) b)
            (or (and (app (lambda _ #f) a)
                     (list))
                (list a))))
   #t])

The bug is on line 209 of scheme/match/compiler.ss, it should be:

(with-syntax ([(esc* success? var ...) (append (generate-temporaries
'(esc* success?)) vars)])

So that esc* gets the same binding in each quasisyntax.

Jay

On Wed, Mar 17, 2010 at 11:36 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> When I run this:
>
> --
> #lang scheme
>
> (define-match-expander const
>  (syntax-rules ()
>    [(_ v p ...)
>     (app (lambda _ v) p ...)]))
> (define-match-expander xexpr
>  (syntax-rules ()
>    [(_ tag attrs body ...)
>     (list-rest
>      tag
>      (or
>       ; If there are attributes it's easy, we just need to ensure
> they are attributes
>       (list (and (attributes _ (... ...))
>                  attrs)
>             body ...)
>       ; If not
>       (and
>        ; we have to make sure empty attrs are allowed
>        (const empty attrs)
>        ; and ensure we aren't missing attrs,
>        (or (list)
>            (list-rest (not (attributes _ (... ...)))
>                       _))
>        ; then continue
>        (list body ...))))]))
> (define-match-expander attributes
>  (syntax-rules ()
>    [(_ attrp ...)
>     (and (list (attr _ _) (... ...))
>          (list-no-order attrp ...))]))
> (define-match-expander attr
>  (syntax-rules ()
>    [(_ key value)
>     (list (? symbol? key)
>           (? string? value))]))
>
> (match `(ul . behavior)
>  [(xexpr tag attrs body ...)
>   (list tag attrs body)])
> --
>
> I get the error:
>
> context (lexical binding) expected 3 values, received 1 value: #f
>
> and a bizarre trace inside match. Is this an error of me or match?
>
> Jay
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://teammccarthy.org/jay
>
> "The glory of God is Intelligence" - D&C 93
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.