(define (doublequoted-symbol? sym)<br> (and (pair? sym) (eqv? (car sym) 'quote)))<br><br>(define-syntax match<br> (syntax-rules ()<br> ((match vars [pfirst prest ...] body ...)<br> <br> (cond<br> <br>
((and (not (doublequoted-symbol? (quote pfirst)))<br> (symbol? (quote pfirst)))<br> (let ((pfirst (car vars)))<br> (match (cdr vars) [prest ...] body ...)))<br> <br> ((eqv? pfirst (car vars))
<br> (match (cdr vars) [prest ...] body ...))<br> <br> (else #f)))<br> <br> ((match vars [] body ...) (begin body ...))))<br><br>(match '(1 2 3) (one 2 three)<br> (display three))<br><br>
<br><br>Sorry for not commenting on the code, but here's a basic idea of what it SHOULD do:<br>(match '(1 2 3) (1 2 3) (display 3)) should match perfectly and display 3 on the terminal (it doesn't).<br>(match '(1 2 3) (one two three) (display 3)) works perfectly, and prints 3.
<br>(match '(1 2 3) ('one 'two 'three) (display 'one)) - This should fail to match the pattern altogether, as symbols which are already quoted are matched for equality, rather than used as identifiers as above. This dies miserably without returning #f.
<br>(match '(1 2 3) (one 2 three) (display three)) - This should immediately create an alias for the values 1 and 3 ('one' and 'three) and match the second values for equality. Unfortunately, this is not the case.
<br><br><br>
(match '(1 2 3) (one 2 three)<br>
(display three))<br>... gives the following error:<br>"let: bad syntax (not an identifier) in: 2"<br><br>It seems to be completely ignoring the conditional.<br>So I performed a test:<br>(and (not (doublequoted-symbol? (quote 2)))
<br> (symbol? (quote 2)))<br>... actually returns FALSE. So then why is the conditional statement branching off completely wrong?<br><br>And then, here's the real kill. I can't debug the damn thing.<br>
Doing so sends an alert window flying in my face, and a larger one behind it.<br><br>"rest: expected argument of type <non-empty list>; given ()<br><br> === context ===<br>C:\Program Files\PLT\collects\mzlib\list.ss:295:2: rest
<br>C:\Program Files\PLT\collects\mztake\debug-tool.ss:804:10: can-step-out?<br><br>rest: expected argument of type <non-empty list>; given ()<br><br> === context ===<br>C:\Program Files\PLT\collects\mzlib\list.ss:295:2: rest
<br>C:\Program Files\PLT\collects\mztake\debug-tool.ss:804:10: can-step-out?<br><br>rest: expected argument of type <non-empty list>; given ()<br><br> === context ===<br>C:\Program Files\PLT\collects\mzlib\list.ss:295:2: rest
<br>C:\Program Files\PLT\collects\mztake\debug-tool.ss:804:10: can-step-out?<br><br>rest: expected argument of type <non-empty list>; given ()<br><br> === context ===<br>C:\Program Files\PLT\collects\mzlib\list.ss:295:2: rest
<br>C:\Program Files\PLT\collects\mztake\debug-tool.ss:804:10: can-step-out?<br><br>rest: expected argument of type <non-empty list>; given ()<br><br> === context ===<br>C:\Program Files\PLT\collects\mzlib\list.ss:295:2: rest
<br>C:\Program Files\PLT\collects\mztake\debug-tool.ss:804:10: can-step-out?<br><br>rest: expected argument of type <non-empty list>; given ()<br><br> === context ===<br>C:\Program Files\PLT\collects\mzlib\list.ss:295:2: rest
<br>C:\Program Files\PLT\collects\mztake\debug-tool.ss:804:10: can-step-out?<br><br>rest: expected argument of type <non-empty list>; given ()<br><br> === context ===<br>C:\Program Files\PLT\collects\mzlib\list.ss:295:2: rest
<br>C:\Program Files\PLT\collects\mztake\debug-tool.ss:804:10: can-step-out?"<br><br>^ Can someone tell me what the hell is going on?<br>