<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>OK, here's some code (at bottom) to work with. Use of MATCH seems to cause a lot of<br>problems. Code is actually Scheme translation of some Logo code from an old TLC Logo<br>book (for the Mattel Aquarius no less) authored by John R. Allen.<br><br>Let me know if anything else is needed.<br><br>Michael<br><br>========== Bad output using MATCH and MATCH-FIRST<br><br>Welcome to DrScheme, version 4.1.2 [3m].<br>Language: Swindle; memory limit: 128 megabytes.<br>> (compare '(likes desi lucy) db)<br>#t<br>> (compare '(likes romeo juliet) db)<br>#t<br>> <br><br>========= Output after replacing MATCH with MMATCH and MATCH-FIRST with MMATCH-FIRST<br>========= Here's the untraced output:<br><br>Welcome to DrScheme, version 4.1.2 [3m].<br>Language: Swindle; memory limit: 128 megabytes.<br>> (compare '(likes desi lucy) db)<br>#f<br>> (compare
'(likes romeo juliet) db)<br>#f<br>> (compare '(likes jack jill) db)<br>#t<br>><br><br>========= And some traced output:<br><br>> (compare '(likes desi lucy) db)<br>|(compare (likes desi lucy) ((likes minnie mickey) (likes jack jill) (likes daisy donald)))<br>| (mmatch (likes desi lucy) (likes minnie mickey))<br>| |(mmatch-first likes likes)<br>| |#t<br>| (mmatch (desi lucy) (minnie mickey))<br>| |(mmatch-first desi minnie)<br>| |#f<br>| #f<br>|(compare (likes desi lucy) ((likes jack jill) (likes daisy donald)))<br>| (mmatch (likes desi lucy) (likes jack jill))<br>| |(mmatch-first likes likes)<br>| |#t<br>| (mmatch (desi lucy) (jack jill))<br>| |(mmatch-first desi jack)<br>| |#f<br>| #f<br>|(compare (likes desi lucy) ((likes daisy donald)))<br>| (mmatch (likes desi lucy) (likes daisy donald))<br>| |(mmatch-first likes likes)<br>| |#t<br>| (mmatch (desi lucy) (daisy donald))<br>| |(mmatch-first desi daisy)<br>| |#f<br>| #f<br>|(compare (likes
desi lucy) ())<br>|#f<br>#f<br><br><br>> (compare '(likes jack jill) db)<br>|(compare (likes jack jill) ((likes minnie mickey) (likes jack jill) (likes daisy donald)))<br>| (mmatch (likes jack jill) (likes minnie mickey))<br>| |(mmatch-first likes likes)<br>| |#t<br>| (mmatch (jack jill) (minnie mickey))<br>| |(mmatch-first jack minnie)<br>| |#f<br>| #f<br>|(compare (likes jack jill) ((likes jack jill) (likes daisy donald)))<br>| (mmatch (likes jack jill) (likes jack jill))<br>| |(mmatch-first likes likes)<br>| |#t<br>| (mmatch (jack jill) (jack jill))<br>| |(mmatch-first jack jack)<br>| |#t<br>| (mmatch (jill) (jill))<br>| |(mmatch-first jill jill)<br>| |#t<br>| (mmatch () ())<br>| #t<br>|#t<br>#t<br>><br><br>========= There's also something screwy going on with the use of Edit|Find and Replace<br>========= that may be associated with the use of MATCH in the code. If I do Edit|Find<br>========= MMATCH and replace it with MATCH (or vice versa) an
extra blank gets inserted<br>========= at the end of MATCH (or MMATCH going the other way), not a problem with MATCH<br>========= but MATCH-FIRST becomes MATCH -FIRST.<br> <br><br>========= Tracing the code also seems to be messed up when using MATCH.<br><br>========= Here's traced output using MATCH and MATCH-FIRST:<br><br>Welcome to DrScheme, version 4.1.2 [3m].<br>Language: Swindle; memory limit: 128 megabytes.<br>> (compare '(likes desi lucy) db)<br>|(compare (likes desi lucy) ((likes minnie mickey) (likes jack jill) (likes daisy donald)))<br>| (match (likes desi lucy) (likes minnie mickey))<br>| |(match-first likes likes)<br>| |#t<br>| (likes minnie mickey)<br>|#t<br>#t<br>> <br><br>================== This code works:<br><br>(require eopl/eopl)<br><br>(define mmatch<br> (λ (pat1 pat2)<br> (if (null? pat1)<br> (null?
pat2)<br> (if (null? pat2)<br> #f<br> (if (mmatch-first (car pat1) (car pat2))<br> (mmatch (cdr pat1) (cdr pat2))<br> #f)))))<br><br>(define mmatch-first<br> (λ (pat1 pat2)<br> (if (symbol? pat1)<br> (if (symbol? pat2)<br> (equal? pat1 pat2)<br> #f)<br> (cond ((symbol? pat2) #f)<br>
((mmatch-first pat1 (car pat2)) (mmatch (cdr pat1) (cdr pat2)))<br> (else #f)))))<br><br>(define compare<br> (λ (q db)<br> (cond ((null? db) #f)<br> (else (cond ((mmatch q (car db)) #t)<br> (else (compare q (cdr db))))))))<br><br><br>(define db '((likes minnie mickey) (likes jack jill) (likes daisy donald)))<br><br>;(trace compare match match-first)<br><br><br>--- On <b>Mon, 12/28/09, Robby Findler <i><robby@eecs.northwestern.edu></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Robby Findler <robby@eecs.northwestern.edu><br>Subject: Re: [plt-scheme] Not so hygienic macros?<br>To:
"michael rice" <nowgate@yahoo.com><br>Cc: plt-scheme@list.cs.brown.edu<br>Date: Monday, December 28, 2009, 10:39 AM<br><br><div class="plainMail">That doesn't sound like a lack of hygiene.<br><br>Its hard to tell what is going on without a program, but my guess is<br>that you wrote a program that boils down to this one:<br><br> #lang scheme<br> (set! match 5)<br><br>and the error message is telling you that you're trying to assign to<br>one of the imports to your library.<br><br>Note that if you had written this:<br><br> #lang scheme<br> (define match 6)<br> (set! match 5)<br><br>the definition of 'match' in the body of the module would have<br>shadowed the import and you'd just get the local version of match<br>only.<br><br>hth,<br>Robby<br><br><br>On Mon, Dec 28, 2009 at 9:28 AM, michael rice <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>>
wrote:<br>><br>> I have a function named MATCH and I seem to be mixing it up with underlying macro code. At least that's what I think is happening.<br>><br>> The error message: set!: cannot mutate syntax identifier in: match<br>><br>> Must I change the name of my function?<br>><br>> Michael<br>><br>><br>> _________________________________________________<br>> For list-related administrative tasks:<br>> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>><br></div></blockquote></td></tr></table><br>