[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] 5. Program Structure



John Cowan writes:
> Andy Wingo scripsit:
> 
> > I think the division of valid kinds of declarations as "variable
> > definitions, syntax definitions, or record-type definitions" is
> > pretty nasty.  I don't see why record-type definitions can't be
> > defined as a sequence of variable and syntax definitions.
> 
> The (IMHO ill-conceived) distinction between primitive and derived
> syntax maintained by the R5RS has not been introduced into
> definitions, library declarations, or procedures.  It's true that a
> record type definition MAY be expanded to a sequence of syntax
> definitions and variable definitions, but there is no requirement
> that this be so: it may be treated as a co-equal primitive form.

What syntax definitions? I thought the expansion needs to define a
constructor, a type predicate, and some accessors and mutators. All
are ordinary variable definitions.

The expansion would be something like the following, which can be
spliced into the definitions in the beginning of a body, to become
letrec* bindings. (I think I first saw this in 1992 or so when records
first failed to enter the language.)

(begin
   (define <rtd> ...)
   (define make-foo (rtd-maker <rtd>))
   (define foo? (rtd-predicate <rtd>))
   (define foo-x (rtd-accessor <rtd> 1))
   (define foo-set-x! (rtd-mutator <rtd> 1)))

Therefore, a record type definition would be simply a (variable)
definition. Same goes for define-values, through a similar trick.

There are just two types of definitions: syntax definitions and
variable definitions. The latter include define-record-type and
define-values.


_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports