[racket-dev] problem with require and frtime

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jan 19 08:13:15 EST 2012

The `frtime' language exports an `=' that isn't the same as `=' in
`racket', so that's why the pattern doesn't match. (This seems like a
further weakness of the `frtime' docs to specify the exports
precisely.)

You could avoid bound names like `=' as literals in the macro.
Normally, it works best for a form-exporting macro to also export
bindings for any literals in the form. Otherwise, this kind of
confusion is common.

Alternatively, you may want to match literals in your macro
symbolically instead of by binding. You can't do that easily with
`syntax-rules', but you can use `syntax-case*' and supply `(lambda (a
b) (eq? (syntax-e a) (syntax-e b)))' as the literal-comparison
function.

If it were me and I decided to go in the direction of symbol equality,
I'd use keywords instead --- `#:?' and `#:=' instead of `?' and `=' ---
which makes clear that there's no question of binding.


At Thu, 19 Jan 2012 10:46:37 +0100, Marijn wrote:
> On 18-01-12 17:47, Matthew Flatt wrote:
> > At Wed, 18 Jan 2012 12:02:10 +0100, Marijn wrote:
> >> I would expect both forms to work. This is a reduction of a different
> >> problem possibly caused by these issues here.
> 
> So I tried to cut down my program to a reasonably sized test-case which
> is attached to this email. model.rkt contains (what's left of) the model
> macro, demo1.rkt contains a small model and a (require frtime). If you
> do "racket demo1.rkt" then you get the following error:
> 
> 
> model.rkt:30:17: make-entry: bad syntax in: (make-entry (= profit
> (for/hash ((y years)) (values y (- (hash-ref income y 0) (hash-ref
> expenses y 0))))) (years income expenses profit))
> 
>  === context ===
> standard-module-name-resolver
> 
> 
> but if you comment the (require frtime) then the error goes away. I have
> other code that tests this same simple-economy model with the
> non-cutdown version of the model macro and supporting code and
> everything seems to work fine.
> 
> Any idea what's going on here?
> 
> Marijn
> 
> ------------------------------------------------------------------------------
> [text/plain "demo1.rkt"] [~/Desktop & open] [~/Temp & open]
> 
> ------------------------------------------------------------------------------
> [text/plain "model.rkt"] [~/Desktop & open] [~/Temp & open]
> 
> ------------------------------------------------------------------------------
> [application/pgp-signature "signature.asc"] [~/Desktop & open] [~/Temp & open]

Posted on the dev mailing list.