[plt-scheme] check-expect not allowed in expression position?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Apr 1 09:44:08 EDT 2010

It's an easy way to get errors: lifting definitions of already defined
things and lifting syntax past where something is defined (which the
current lifters can already do.)

Here's something bizarre that you could do:

#lang scheme
(define-syntax (weird stx)
  (syntax-case stx ()
    [(_ thing)
     (with-handlers ([void
                      (lambda (x)
                        (syntax-local-lift #`(define-syntax thing #'1))
       (syntax-local-value #'thing))]))

(define-syntax test1 #'1)
(weird test1)
(weird test2) ; lifts
(weird test2) ; doesn't lift

If the syntax isn't defined, then you do one thing, otherwise you do
another. But, if you had already done the lift, then it would be
available to this macro. Now the "effects" of macro expansion are even
more bizarre than they are normally.


On Wed, Mar 31, 2010 at 12:41 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
>>> After seeing the error, I now understand that I misused
>>> syntax-local-lift-module-end-declaration, which says that, in the way
>>> I'm using it, eventually the thing being lifted will be expanded in
>>> expression context.  Of course, this isn't what I want: I want to lift
>>> a syntax up to the module or top-level context.  I can't find the
>>> right primitive that does this.  Am I missing something obvious?
>> At a more meta level, you're never gonna get this because it has nasty
>> paradox problems for definitions. I've slowly come to accept this by
>> thinking about why I shouldn't be able to lift the top level
>> definitions I want to, etc.
> Do you have an example of a paradox that would come up?  I've been
> trying to think of one, but my imagination's a bit weak.

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.