How do I define functions using PLT Scheme macros?

Posted by nickname on Stack Overflow See other posts from Stack Overflow or by nickname
Published on 2010-05-23T02:19:23Z Indexed on 2010/05/23 3:10 UTC
Read the original article Hit count: 399

Filed under:
|
|

I am trying to write a macro that defines a special class of data structure with associated functions.

I know this is possible; it is done multiple times in the core language itself.

As a specific example, how would I define the define-struct macro in Scheme itself. It needs to create make-struct, struct-<<field>>, etc functions.

I tried doing this using define, however, this only defines the function in the macro's lexical scope.

How can I actually define a function in a macro?

© Stack Overflow or respective owner

Related posts about macros

Related posts about Scheme