commit 887d54e6340927820689b601cc9bb613f250a582
parent dd1394ef48f67c13ecfb214ec10b8762ac89c405
Author: Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
Date: Mon, 17 Aug 2015 11:18:58 +0200
Use car/cdr symbols, not procedures.
Diffstat:
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/srfi-123.html b/srfi-123.html
@@ -44,7 +44,7 @@ class="antispam">nospam</span>srfi.schemers.org</a></code>. To subscribe to the
(set! (~ table "foo") "Foobar.")
(ref table "foo") ;=> "Foobar."
(ref table "bar") ;error: Object has no entry for field.</code></pre></li>
-<li><p>When a pair is encountered, the field argument may be the procedures <code>car</code> or <code>cdr</code>, or an integer index indicating the pair should be viewed as the head of a list.</p>
+<li><p>When a pair is encountered, the field argument may be the symbols <code>car</code> or <code>cdr</code>, or an integer index indicating the pair should be viewed as the head of a list.</p>
<pre><code>(ref '(a b c . d) cdr) ;=> (b c . d)
(ref '(a b c . d) 2) ;=> c</code></pre></li>
<li><p>For records, the accepted values for the <code>field</code> parameter are symbols corresponding to the record type's field names. The overhead involved in looking up the correct accessor of modifier falls under the same rationale as other kinds of overhead involved with this SRFI.</p>
diff --git a/srfi-123.md b/srfi-123.md
@@ -95,7 +95,7 @@ types; SRFI-9 and R7RS cannot.) Some notes on specific types:
(ref table "bar") ;error: Object has no entry for field.
```
-- When a pair is encountered, the field argument may be the procedures
+- When a pair is encountered, the field argument may be the symbols
`car` or `cdr`, or an integer index indicating the pair should be
viewed as the head of a list.
diff --git a/srfi/123.body.scm b/srfi/123.body.scm
@@ -37,9 +37,9 @@
(define (pair-ref pair key)
(cond
- ((eqv? car key)
+ ((eqv? 'car key)
(car pair))
- ((eqv? cdr key)
+ ((eqv? 'cdr key)
(cdr pair))
(else
(list-ref pair key))))