The line numbers and everything else refer to
https://github.com/scheme-requests-for-implementation/srfi-204/blob/master/srfi/204/204.scm
On Sun, Apr 25, 2021 at 5:35 PM Felix Thibault <xxxxxx@gmail.com> wrote:
>
> I have the everything in library or program form and am working on the
> late binding. Marc suggesting changing the last part of match two
> which binds the pattern variable to its value like:
>
>
> ;; Not a pair or vector or special literal, test to see if it's a
> ;; new symbol, in which case we just bind it, or if it's an
> ;; already bound symbol or some other literal, in which case we
> ;; compare it with EQUAL?.
> ((match-two v x g+s (sk ...) fk (id ...)) ;; LINE#502
> (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)))
>
> to binding the value to a temporary:
> ((match-two v x g+s (sk ...) fk ((id . id%) ...)) ;CHANGE
> (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)) (ask ... ((id . id%) ... (x . x%))) ;CHANGE
> (if (equal? v x) (sk ... (id ...)) fk)))
> (if (equal? v x) (sk ... (id ...)) fk)))
>
> and then binding the temporaries at this step:
> ((match-next v g+s (pat (=> failure) . body) . rest) ;LINE#336
> (let ((failure (lambda () (match-next v g+s . rest))))
> ;; match-one analyzes the pattern for us
> (match-one v pat g+s (match-drop-ids (begin . body)) (failure) ())))
>
> Which I am attempting by replacing match-drop-ids, the macro that runs
> the body by dropping everything but the first expression:
> (define-syntax match-drop-ids
> (syntax-rules ()
> ((_ expr ids ...)
> (expr))))
>
> with:
> (define-syntax match-bind-ids
> (syntax-rules ()
> ((_ expr ((id . id%) ...) ...)
> (let ((id id%) ... ...)
> expr))))
>
> Which is giving me a bad let on (match 1 (a a)) that looks like
> (let ((a) (a%)) (begin a))
>
> I am thinking either one or both of these macros is wrong, (or that
> there are also changes I need to make in match-extract-vars- which I
> am having trouble understanding), but I am not sure which step to take
> next.