[plt-scheme] flawed syntax definition of require in slibinit

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Mar 31 13:25:22 EST 2003

At Sun, 30 Mar 2003 19:03:20 +0200, Andreas Voegele wrote:
> There are two functions in slib/dbutil.scm that require a feature in
> the following way:
> 
>  (define (create-database filename type)
>    (require type)
>    ...)

I see. The problem is that `(require type)' could be a use of
MzScheme's `require', too --- but only at the top level.

> The problem is caused by the following code in slibinit/init.ss.  It
> seems that the situation outlined above is not handled.
> 
>  (define-syntax (require stx)
>    (syntax-case stx (quote)
>      [_
>       (identifier? stx)
>       #'slib:require]
>      [(_ (quote something))
>       #'(slib:require (quote something))]
>      [(_ req ...)
>       #'(mz:require req ...)]))
> 
> Wouldn't it be better to make slib:require the default case and to
> check for mz:require instead?

Possibly, but I'm not sure.

For now, I've adjusted the macro to use `slib:require' whenever the
context of the `require' use isn't the top level.

> Or maybe an expression that is evaluated at run time could be used
> instead of a syntax definition.

This won't work, because a use of MzScheme's `require' has to be
visible at expansion time.

Matthew



Posted on the users mailing list.