[racket] Macros that expand to field and method definitions

From: Patrick Mahoney (paddy.mahoney at gmail.com)
Date: Wed Apr 25 03:19:46 EDT 2012

#|Hello all,

I'm looking to define a macro that extends the forms within a racket/class
class%. In particular, I would like a form to define a C# like class
language form property, that implements the getters and setters for an
initialized field automatically.

I'm guessing that someone has written this before however. Can anyone
assist with macros that expand into class fields and methods? Ideally, I'd
like to move to syntax-parse. |#

(define-syntax (define-property syntax)
  (syntax-parse syntax
                [((~literal define-property) name:id init-value)

                 #'(define name init-value)
                 (define/public (set-name! init-value)
                   (set! name init-value))
                 (define/public (get-name)
define/public: use of a class keyword is not in a class top-level in:
(define/public (set-name! init-value) (set! name init-value))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120425/125cccae/attachment.html>

Posted on the users mailing list.