Next: overview repl, Previous: overview restrictions, Up: overview [Index]
Here is a list of implementation extensions which may be non–compliant with R6RS.
(import (rnrs)) (define-record-type alpha (fields a) (protocol (lambda (A) ---))) ;; this is good (define-record-type beta (parent alpha) (fields b) (protocol (lambda (A B) ---))) ;; this is bad according to R6RS!!! (define-record-type gamma (parent alpha) (fields b))
This restriction is violated by Vicare, which allows the following:
(import (rnrs)) (define-record-type alpha (fields a) (protocol (lambda (A) ---))) ;; this is good in Vicare!!! (define-record-type beta (parent alpha) (fields b))
Vicare just expects the parent protocol function to have the same interface of a default protocol function.
vicare is run without the option
--strict-r6rs: the syntax define-record-type
automatically generates unsafe field accessor and mutator syntaxes; in
the following example:
(define-record-type color
(fields (mutable red)
(mutable green)
(mutable blue)))
in addition to the safe accessor and mutator definitions for:
color-red color-red-set! color-green color-green-set! color-blue color-blue-set!
unsafe accessors and mutator definitions for:
$color-red $color-red-set! $color-green $color-green-set! $color-blue $color-blue-set!
are generated with code like:
(define-syntax $color-red
(syntax-rules ()
((_ x)
($struct-ref x 0))))
(define-syntax $color-red-set!
(syntax-rules ()
((_ x v)
($struct-set! x 0 v))))
Notice that the name of the unsafe accessors and mutators is always built from the field name, not from the custom names given in the definition; for example:
(import (rnrs))
(define-record-type color
(fields (mutable red the-red set-the-red!)
(mutable green the-green set-the-green!)
(mutable blue the-blue set-the-blue!)))
(define X
(make-color 1 2 3))
(define Y
(make-color 1 2 3))
(set-the-red! X 10)
(set-the-green! X 20)
(set-the-blue! X 30)
(list (the-red X)
(the-green X)
(the-blue X)))
⇒ (10 20 30)
($color-red-set! Y 10)
($color-green-set! Y 20)
($color-blue-set! Y 30)
(list ($color-red Y)
($color-green Y)
($color-blue Y)))
⇒ (10 20 30)
Next: overview repl, Previous: overview restrictions, Up: overview [Index]