[plt-scheme] paren-shape bug?

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Tue Apr 28 18:03:23 EDT 2009

On Tue, 28 Apr 2009, Ryan Culpepper wrote:

> Beware: if you write macros whose bodies contain square brackets, those 
> square brackets will turn to round parentheses if you compile the file. You 
> might want to replace 'syntax' (and 'quasisyntax', et al) in your language 
> with a version that explicitly preserves those properties.

Actually, this is something that has been bugging me for a while with 
compiled code, but I don't know the right way to fix it.
The straightforward syntax walk with syntax/quasisyntax wrapper macros 
doesn't work:
1) it results in syntax that still loses properties depending on how you
    structure it [perhaps that was the bug hitting me in the past, but I
    hadn't isolated it]
2) it incurs quadratic expansion overhead, because syntax wraps are no
    longer lazy!

I can think of two solutions that work to some extend, but both are 
1) quasisyntax and explicitly unsyntax and syntax-property wrap.
    This is very ugly and it doesn't scale to complex macros.
2) Use a reader macro that wraps properties into special purpose macros
    that force the property when expanded.

In principle (2) works, but it has a subtle problem: it changes paren 
semantics in macros and you can no longer use []/{} as visual sugar any 

Any ideas on how to fix this problem? Ideally the compiler wouldn't dump 
the properties as it currently does, but I don't know how feasible this 

-- vyzo

Posted on the users mailing list.