On Wed, Feb 26, 2014 at 3:18 PM, David Vanderson <[email protected]> wrote: > > On 02/26/2014 01:54 PM, Matthew Butterick wrote: >> Q: How could I invoke 'public-proc' for its syntax-generating effect in >> the main module, yet have it adopt the binding of 'private-proc' in the main >> module? >> >> I gather roughly that it requires tampering with the lexical information >> of the syntax objects. Then things get hazy. > > I think you are looking for define-macro, so that you can defeat hygiene. > Of course this comes with all of the normal caveats about the dangers of > breaking hygiene, so if this is what you're looking for, can you describe > why you want to do it?
As I've recently started to try using Typed Racket more seriously, I've encountered this situation. (It may be different than Matthew's case, but I think it's the same basic technical issue.) You want to use an untyped library in typed code. `require/typed` works great to create wrappers of functions. However, the library also provides some syntax, which expands into those functions. The problem is, it will expand into the raw untyped functions, _not_ the wrappers. The normally helpful feature bites you in this case. Fixing this might break hygiene, but in a desirable way. Syntax parameters let you break hygiene for a certain category of applications in a safe way. Furthermore, using syntax parameters makes the intent clear. I wish there were a mechanism like syntax parameters to help with this issue of macros from untyped libraries. In decreasing order of preference: 1. `require/typed` would let you supply specific syntax transformers from the library, and cause the macro expander behave differently. i.e. "Given this set of wrapped functions, and this set of macros, make the latter expand using the former." This is most-preferable because, like `require/typed` already does for functions, it would let you work with an existing untyped library even if you're unwilling or unable to modify its source. 2. Some mechanism in the same spririt as syntax parameters, that enables a well-intentioned untyped library writer to supply macros that will work with `require/typed`. This is less-preferred because it requires the library writer to do it completely (not overlook some macro), or for that matter to do it at all. 3. The status quo. You copypasta the macro source into your typed/racket module. Technically clunky and in some cases legally not possible. ____________________ Racket Users list: http://lists.racket-lang.org/users

