[plt-scheme] Not so hygienic macros?
OK, I'm using #lang scheme and the Module language now.
But I'm still getting an extra blank inserted when I replace MATCH with MMATCH (see MMATCH- FIRST below). Is the replace function supposed to work this way?
Michael
========
(define mmatch
(λ (pat1 pat2)
(if (null? pat1)
(null? pat2)
(if (null? pat2)
#f
(if (mmatch -first (car pat1) (car pat2))
(match (cdr pat1) (cdr pat2))
#f)))))
--- 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: "Shriram Krishnamurthi" <sk at cs.brown.edu>, "plt-scheme" <plt-scheme at list.cs.brown.edu>
Date: Tuesday, December 29, 2009, 9:17 AM
With modules you get error messages (more often) when things won't work. In this case, I'd say it is probably easier to use mzlib/trace instead, tho.
#lang scheme
(require mzlib/trace)
(define (f x)
(if (zero? x)
x
(+ (f (- x 1)) 1)))
(trace f)
(f 10)
On Tue, Dec 29, 2009 at 7:44 AM, michael rice <nowgate at yahoo.com> wrote:
Yep, there it was, and somehow I missed it.
Also, I was using (require eopl/eopl) for tracing. Is that now OK, or still verboten?
Michael
--- On Tue, 12/29/09, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
From: Shriram Krishnamurthi <sk at cs.brown.edu>
Subject: Re: [plt-scheme] Not so hygienic macros?
To: "michael rice" <nowgate at yahoo.com>
Cc: "Robby Findler" <robby at eecs.northwestern.edu>, plt-scheme at list.cs.brown.edu
Date: Tuesday, December 29, 2009, 8:10 AM
It's the topmost entry. It looks like it's missing a heading.
On Tue, Dec 29, 2009 at 7:29 AM, michael rice <nowgate at yahoo.com> wrote:
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)))
_________________________________________________
For list-related administrative tasks:
http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091229/781e3d2a/attachment.html>