[R6RS] records comments

dyb at cs.indiana.edu dyb
Fri Jul 8 17:32:31 EDT 2005


[NB: I've moved this to the mailing list.]

Thanks for your feedback, Marc.

> I think the syntax in your proposal is too verbose.  Defining a  
> record type should be no longer than
>
>     (define-type point x y)
>
> otherwise people will not use it.  I'm hoping I can find some time in  
> the next few days to propose a different syntax.

It is a bit verbose for the simplest record definitions with implicitly
named products.  If you and others find it too verbose, we can define
some shorthands that make it just as simple as you have above.  In the
full syntax, we would write:

  (define-type point (x y) (fields [(mutable x) x] [(mutable y) y)])

If we make fields mutable by default, we can allow this instead:

  (define-type point (x y) (fields [x x] [y y]))

If this isn't enough, we can also say that with no fields declaration,
there is one field per maker formal, each initialized by the corresponding
maker actual, so that we can write:

  (define-type point (x y))

I'm willing to include these shorthands if that's what it will take to
reach agreement on something we can put into the report.  I'd prefer not
to, however, because (a) I don't find the added verbosity of the original
bad at all and don't believe that it will cause people to avoid using
it, (b) I think it's a good idea to force people to specify mutability
and field initialization explicitly, and (c) people who really want
such shorthands can define their own shorthand syntax as a wrapper
for define-type.

An important feature of the syntax we propose is that it extends
gracefully to explicit naming, e.g.:

  (define-type (point make-point point?) (x y)
    (fields
      [(mutable x get-x set-x!) x]
      [(immutable y get-y) y]))

You may not like the positional specification of the type, maker,
and predicate names, but people who *always* specify names explicitly
(including Mike, Will, and probably many others) will certainly find
this preferable to a keyword-based syntax.

It also extends gracefully to nontrivial field initialization, e.g.:

  (define-type point (x y)
    (fields
      [(immutable x) x]
      [(immutable y) (build-table y)]
      [(mutable z) 0]))

Kent


More information about the R6RS mailing list