Re: specification by implications and example Per Bothner 17 Jan 2000 08:18 UTC

Shriram Krishnamurthi <xxxxxx@cs.rice.edu> writes:

> You should also edit the
> "Standard setters" section to be of the form
>   (setter car-proc) --> set-car!
> where car-proc is eq? to the built-in primitive car, and so forth,
> rather than the current format.

I agree, though I don't see the point of using `car-proc'
rather than `car'.  It seems unnecessary to me.

--- srfi-17.html	Sun Jan 16 17:46:20 2000
+++ srfi-17.html.new	Mon Jan 17 00:16:58 2000
@@ -155,21 +155,40 @@
 is more intuitive, and has the big advantage that many
 existing functions already have proper setters.
 My tentative recommendation is alternative 1.
+<p>
+The formal definition is thus:
+<pre>
+(define-syntax set!
+  (syntax-rules ()
+    ((set! (proc arg ...) value)  ;; Assuming Alternative 1
+     ((setter proc) arg ... value))
+    ;; ((set! (proc arg ...) value) ;; Assuming Alternative 2
+    ;;  ((setter proc) value arg ...))
+    ((set! var value)
+     (%%builtin-set! var value))))
+</pre>
+- where <code>%%builtin-set!</code> is the R5RS version of <code>set!</code>,
+and <code>setter</code> is a new standard procedure that maps procedures
+to their setters.  If the procedure has no setter, then <code>setter</code>
+signals an error.

 <h2>Standard setters</h2>
 <p>
 The following standard procedures have pre-defined setters:
 <pre>
-(set! (car x) v) == (set-car! x v)
-(set! (cdr x) v) == (set-cdr! x v)
-(set! (caar x) v) == (set-car! (car x) v)
-(set! (cadr x) v) == (set-car! (cdr x) v)
+(setter car) --> set-car!
+(setter cdr) --> set-cdr!
+(setter caar) --> (lambda (x v) (set-car! (car x) v))
+;; Hence: (set! (caar x) v) == (set-car! (car x) v)
+(setter cadr) --> (lambda (x v) (set-car! (cdr x) v))
 ....
-(set! (caXXr x) v) == (set-car! (cXXr x) v)
-(set! (cdXXr x) v) == (set-cdr! (cXXr x) v)
-(set! (string-ref x i) v) == (string-set! x i v)
-(set! (vector-ref x i) v) == (vector-set! x i v)
+(setter caXXr) --> (lambda (x v) (set-car! (cXXr x) v))
+(setter cdXXr) --> (lambda (x v) (set-cdr! (cXXr x) v))
+(setter string-ref) -> string-set!
+(setter vector-ref) -> vector-set!
 </pre>
+(Here <code>car</code>, <code>set-car!</code>, and so on refer
+to their initial values in <code>(scheme-report-environment 5)</code>.)

 <!--
 <p>
@@ -301,7 +320,7 @@
     <address>Editor: <a href="mailto:xxxxxx@schemers.org">Mike Sperber</a></address>
 <!-- Created: Wed Nov 10 03:14:43 PST 1999 -->
 <!-- hhmts start -->
-Last modified: Sun Jan 16 10:45:36 MET 2000
+Last modified: Sun Jan 16 17:45:11 PST 2000
 <!-- hhmts end -->
   </body>
 </html>

--
	--Per Bothner
xxxxxx@bothner.com   http://www.bothner.com/~per/