commit 5a6aee5c60d3898f36217163d4205c8650d0704d
parent 887d54e6340927820689b601cc9bb613f250a582
Author: Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
Date: Mon, 17 Aug 2015 11:24:22 +0200
Make define-record-type a definition again.
Diffstat:
3 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/srfi-123.html b/srfi-123.html
@@ -101,7 +101,6 @@ class="antispam">nospam</span>srfi.schemers.org</a></code>. To subscribe to the
<p>The intent of this SRFI is to encourage Scheme systems to extend their standard library in accordance with the above specification. On the meanwhile, the reference implementation can be used as a separate library, but certain considerations apply.</p>
<p>The <code>define-record-type</code> export of the library conflicts with the one in <code>(scheme base)</code>, so either has to be renamed, or more typically, the one from <code>(scheme base)</code> excluded.</p>
<p>Record types not defined with the <code>define-record-type</code> exported by this library won't work with <code>ref</code> and <code>ref*</code>.</p>
-<p>The <code>define-record-type</code> exported by this library expands to a record type definition followed with a command, essentially eliminating the "definition" status of <code>define-record-type</code>. This means, for example, that you can't use it more than once (only at the end) within the internal definitions sequence of a body. It's a rare use-case, but if you need it, you can nest each additional <code>define-record-type</code> use in a further <code>(let () ...)</code>. It works fine in the top-level, since there definitions and commands can be interspersed.</p>
<h2 id="implementation">Implementation</h2>
<p>A reference implementation as a library is found in the version control repository of this SRFI.</p>
<p>It might be desirable for Scheme systems to offer a more efficient <code>type-of</code> procedure than the one used in this implementation, which in the worst case consumes linear time with regard to the number of types (including every record type) within the system, albeit with a very small constant factor: one call to each type predicate.</p>
diff --git a/srfi-123.md b/srfi-123.md
@@ -233,15 +233,6 @@ the one from `(scheme base)` excluded.
Record types not defined with the `define-record-type` exported by
this library won't work with `ref` and `ref*`.
-The `define-record-type` exported by this library expands to a record
-type definition followed with a command, essentially eliminating the
-"definition" status of `define-record-type`. This means, for example,
-that you can't use it more than once (only at the end) within the
-internal definitions sequence of a body. It's a rare use-case, but if
-you need it, you can nest each additional `define-record-type` use in
-a further `(let () ...)`. It works fine in the top-level, since there
-definitions and commands can be interspersed.
-
Implementation
--------------
diff --git a/srfi/123.body.scm b/srfi/123.body.scm
@@ -183,11 +183,15 @@
((_ <name> <constructor> <pred> <field> ...)
(begin
(%define-record-type <name> <constructor> <pred> <field> ...)
- (register-getter-with-setter!
- <pred>
- (getter-with-setter (record-getter <field> ...)
- (record-setter <field> ...))
- #f)))))
+ ;; Throw-away definition to not disturb an internal definitions sequence.
+ (define __throwaway
+ (begin
+ (register-getter-with-setter!
+ <pred>
+ (getter-with-setter (record-getter <field> ...)
+ (record-setter <field> ...))
+ #f)
+ #f))))))
(define-syntax record-getter
(syntax-rules ()