Email list hosting service & mailing list manager

var syntax Felix Thibault (21 Jan 2021 14:50 UTC)
Re: var syntax Marc Nieper-Wißkirchen (21 Jan 2021 15:06 UTC)
(missing)
(missing)
Fwd: var syntax Felix Thibault (21 Jan 2021 15:37 UTC)
Re: var syntax Marc Nieper-Wißkirchen (21 Jan 2021 15:57 UTC)
Re: var syntax Felix Thibault (21 Jan 2021 16:31 UTC)
Re: var syntax Marc Nieper-Wißkirchen (22 Jan 2021 12:58 UTC)
Re: var syntax Felix Thibault (22 Jan 2021 23:34 UTC)
Re: var syntax John Cowan (23 Jan 2021 06:02 UTC)
Re: var syntax Marc Nieper-Wißkirchen (23 Jan 2021 09:03 UTC)
Re: var syntax Felix Thibault (23 Jan 2021 14:22 UTC)
Re: var syntax Marc Nieper-Wißkirchen (23 Jan 2021 14:41 UTC)
(missing)
Fwd: var syntax Felix Thibault (25 Jan 2021 10:52 UTC)

Re: var syntax Felix Thibault 21 Jan 2021 16:31 UTC

On Thu, Jan 21, 2021 at 10:56 AM Marc Nieper-Wißkirchen
<xxxxxx@nieper-wisskirchen.de> wrote:

> The difference is hygiene, which effectively renames the macro's "var". Binding "syn" in the macro never binds "var" as seen by the macro. So you do not have to worry about the macro, you just  have to worry about the correct semantics of
>
> (match '(1 1) (((var var) (var var))) var))
>
> It should really match and evaluate to 1.
>
> Another test case is:
>
> (match '(2 1) (((var and) (and 1 x)) (list and x))
>
> This should, in my opinion, evaluate to (2 1).
>
Well, that matches '(2 (2 1 3)), which is like '(1 (1 1)): not what
was intended. I'm new at this whole macro business, so I don't really
know what would be involved in making this library late binding- it
sounds like a complete re-implementation. The way var is set up right
now is there is this block in match-one:

((match-one v (var x) g+s (sk ...) fk (id ...))
     (match-check-identifier
      x
      (let-syntax
          ((new-sym?
            (syntax-rules (id ...)
              ((new-sym? x sk2 fk2) sk2)
              ((new-sym? y sk2 fk2) fk2))))
        (new-sym? random-sym-to-match
                  (let ((x v)) (sk ... (id ... x)))
                  (if (equal? v x) (sk ... (id ...)) fk)))
      (if (equal? v x) (sk ... (id ...)) fk)))

and this block in match-extract-vars:

((match-extract-vars (var p) (k ...) (i ...) v)
     (let-syntax
         ((new-sym?
           (syntax-rules (i ...)
             ((new-sym? p sk fk) sk)
             ((new-sym? any sk fk) fk))))
       (new-sym? random-sym-to-match
                 (k ... ((p p-ls) . v))
                 (k ... v))))

and maybe there is some obvious mistake I made in these macros.