[plt-scheme] Not so hygienic macros?

From: michael rice (nowgate at yahoo.com)
Date: Tue Dec 29 07:29:12 EST 2009

What is the "Module" language? Don't see it in any of the language selection menus.

Michael

--- On Tue, 12/29/09, Robby Findler <robby at eecs.northwestern.edu> wrote:

From: Robby Findler <robby at eecs.northwestern.edu>
Subject: Re: [plt-scheme] Not so hygienic macros?
To: "michael rice" <nowgate at yahoo.com>
Cc: plt-scheme at list.cs.brown.edu
Date: Tuesday, December 29, 2009, 2:21 AM

On Mon, Dec 28, 2009 at 9:02 PM, michael rice <nowgate at yahoo.com> wrote:
> OK, here's some code (at bottom) to work with. Use of MATCH seems to cause a lot of
> problems. Code is actually Scheme translation of some Logo code from an old TLC Logo
> book (for the Mattel Aquarius no less) authored by John R. Allen.

I think you're running into what Matthew calls "hopeless top-level
problems". Eli can probably say more about what is going on with the
Swindle language that leads to these precise results.

In the meatime, I think that if you use the module language, I think
you'll find that the program behaves much more sanely. That is, get
rid of the eopl require, prefix the program with "#lang scheme", and
use the "Module" language to run the program in DrScheme. When I do
that, both versions of the program, the one you posted, and the one
below, behave identically on the example inputs you send, namely
producing #f for both of these calls:

  (compare '(likes desi lucy) db)
  (compare '(likes romeo juliet) db)

hth,
Robby

#lang scheme

(define match
  (λ (pat1 pat2)
    (if (null? pat1)
        (null? pat2)
        (if (null? pat2)
            #f
            (if (match-first (car pat1) (car pat2))
                (match (cdr pat1) (cdr pat2))
                #f)))))

(define match-first
  (λ (pat1 pat2)
    (if (symbol? pat1)
        (if (symbol? pat2)
            (equal? pat1 pat2)
            #f)
        (cond ((symbol? pat2) #f)
              ((match-first pat1 (car pat2)) (match (cdr pat1) (cdr pat2)))
              (else #f)))))

(define compare
  (λ (q db)
    (cond ((null? db) #f)
          (else (cond ((match q (car db)) #t)
                      (else (compare q (cdr db))))))))

(define db '((likes minnie mickey) (likes jack jill) (likes daisy donald)))



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091229/318ea1ed/attachment.html>

Posted on the users mailing list.