Small modification Olin Shivers (10 Jul 1999 04:27 UTC)
|
Re: Small modification
Richard Kelsey
(12 Jul 1999 18:56 UTC)
|
Re: Small modification
Olin Shivers
(12 Jul 1999 20:35 UTC)
|
Re: Small modification
Sergei Egorov
(12 Jul 1999 21:23 UTC)
|
Re: Small modification
Matthias Felleisen
(12 Jul 1999 21:29 UTC)
|
Small modification Olin Shivers 10 Jul 1999 04:32 UTC
I am strongly in favor of Richard's proposal. Being syntax, it gives enough static information to allows compilers to provide efficient implementations of records. However, it doesn't build in particular naming conventions. It's the right policy/mechanism split -- others can build particular record packages on top of this low-level system, since it is completely neutral with respect to naming conventions. When Kent Dybvig described his record proposal at the ICFP Scheme workshop in Baltimore, I actually wrote up a naming-neutral counterproposal to Kent's system which is almost exactly what Richard has proposed. My proposal had two smalldifferences, which I'll put forth for consideration. First, put the field-spec's in their own list. That is, don't write this (define-record-type :ship (make-ship size name) ; No speed parameter. ship? (size ship-size set-ship-size!) ; Settable (name ship-name) ; Not settable (speed ship-speed set-ship-speed!)) ; Settable Instead, write this: (define-record-type :ship (make-ship size name) ; No speed parameter. ship? ((size ship-size set-ship-size!) ; Settable (name ship-name) ; Not settable (speed ship-speed set-ship-speed!))) ; Settable This allows future SRFIs to extend this SRFI's syntax with extra items, such as Dybvig's meta-programming hooks, or "method definitions" for generic operations such as printing or disclosing. For example, one might want an extension such as (define-record-type :ship (make-ship size name) ; No speed parameter. ship? ((size ship-size set-ship-size!) ; Settable (name ship-name) ; Not settable (speed ship-speed set-ship-speed!)) ; Settable ;; This method is used to print ship records ((display self port) (display "#{ship " port) (display (ship-name self) port) (display "}" port))) Second, Dybvig's old higher-level proposal had one extra field, an identifier field, which was a value that was put into the record type descriptor for use by the introspection facilities (e.g., the debugger). I allowed for this in my proposal, so you wrote (define-record-type ship :ship (make-ship size name) ...) The "ship" symbol appearing as the first form was the identifier field. This is not ultra-important, but I thought I'd throw it out. -Olin