Hello,

Something I use heavily in the 'box2d-lite' code is a
'define-record-type++' macro:

http://github.com/dharmatech/box2d-lite/blob/master/util/define-record-type.sls

It expands into a call to the full 'define-record-type' along with some
additional definitions.

However, it's cheesy in that it only supports a subset of the syntax of
the full 'define-record-type', along with some additional syntax.

Is there a pure R6RS definition of the 'define-record-type' macro
available somewhere? The definitions I found had implementation specific
code in them.

I'd rather base my 'define-record-type' deriviative on a full version.
I.e. start with the full definition and throw in my extensions.

Here's an example usage of 'define-record-type++':

  (define-record-type++ world
    is-world
    import-world
    (fields (mutable bodies)
            (mutable joints)
            (mutable arbiters)
            (mutable gravity)
            (mutable iterations))
    (methods (add-body world::add-body)
             (clear world::clear)
             (step world::step)))


from this library:

    http://github.com/dharmatech/box2d-lite/blob/master/world.sls

If I say:

    (is-world w)

I can access a field of 'w':

    w.bodies

I can set a field:

    (w.bodies! some-val)

I can call a "method":

    (w.add-body some-val)

The 'import-world' macro is similar, except the generated names won't
have the 'var.' prefix; it's for use in the body of a "method".

Ed

Reply via email to